@@ -48,8 +48,10 @@ export class DonateGoldExecution implements Execution {
4848 this . sender . donateGold ( this . recipient , this . gold )
4949 ) {
5050 // Give relation points based on how much gold was donated
51- const relationUpdate = this . calculateRelationUpdate ( Number ( this . gold ) ) ;
52- this . recipient . updateRelation ( this . sender , relationUpdate ) ;
51+ const relationUpdate = this . calculateRelationUpdate ( this . gold ) ;
52+ if ( relationUpdate > 0 ) {
53+ this . recipient . updateRelation ( this . sender , relationUpdate ) ;
54+ }
5355 } else {
5456 console . warn (
5557 `cannot send gold from ${ this . sender . name ( ) } to ${ this . recipient . name ( ) } ` ,
@@ -58,26 +60,27 @@ export class DonateGoldExecution implements Execution {
5860 this . active = false ;
5961 }
6062
61- getGoldChunkSize ( ) : number {
63+ getGoldChunkSize ( ) : Gold {
6264 const { difficulty } = this . mg . config ( ) . gameConfig ( ) ;
6365 switch ( difficulty ) {
6466 case Difficulty . Easy :
65- return this . random . nextInt ( 1 , 2_500 ) ;
67+ return BigInt ( this . random . nextInt ( 1 , 2_500 ) ) ;
6668 case Difficulty . Medium :
67- return this . random . nextInt ( 2_500 , 5_000 ) ;
69+ return BigInt ( this . random . nextInt ( 2_500 , 5_000 ) ) ;
6870 case Difficulty . Hard :
69- return this . random . nextInt ( 5_000 , 12_500 ) ;
71+ return BigInt ( this . random . nextInt ( 5_000 , 12_500 ) ) ;
7072 case Difficulty . Impossible :
71- return this . random . nextInt ( 12_500 , 25_000 ) ;
73+ return BigInt ( this . random . nextInt ( 12_500 , 25_000 ) ) ;
7274 default :
73- return 2_500 ;
75+ return 2_500n ;
7476 }
7577 }
7678
77- calculateRelationUpdate ( goldSent : number ) : number {
79+ calculateRelationUpdate ( goldSent : Gold ) : number {
7880 const chunkSize = this . getGoldChunkSize ( ) ;
7981 // Calculate how many complete chunks were donated
80- const chunks = Math . floor ( goldSent / chunkSize ) ;
82+ // BigInt division automatically truncates (integer division)
83+ const chunks = Number ( goldSent / chunkSize ) ;
8184 // Each chunk gives 5 relation points
8285 const relationUpdate = chunks * 5 ;
8386 // Cap at 100 relation points
0 commit comments