diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 347e10b33f..68216dbbc1 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -11,6 +11,7 @@ namespace OpenRa.Game public Race Race; public readonly int Index; public int Cash; + public int Ore; public int DisplayCash; int powerProvided; int powerDrained; @@ -24,6 +25,7 @@ namespace OpenRa.Game this.PlayerName = playerName; this.Race = race; this.Cash = 10000; + this.Ore = 0; this.DisplayCash = 0; this.powerProvided = this.powerDrained = 0; @@ -49,15 +51,21 @@ namespace OpenRa.Game return 0.5f; /* todo: work this out the same way as RA */ } - public void GiveCash( int num ) - { - Cash += num; - } + public void GiveCash( int num ) { Cash += num; } + public void GiveOre(int num) { Ore += num; } public bool TakeCash( int num ) { - if (Cash < num) return false; - Cash -= num; + if (Cash + Ore < num) return false; + if (Ore <= num) + { + num -= Ore; + Ore = 0; + Cash -= num; + } + else + Ore -= num; + return true; } @@ -71,16 +79,18 @@ namespace OpenRa.Game if (this == Game.LocalPlayer) { - if (DisplayCash < Cash) + var totalMoney = Cash + Ore; + + if (DisplayCash < totalMoney) { - DisplayCash += Math.Min(displayCashDeltaPerFrame, - Cash - DisplayCash); + DisplayCash += Math.Min(displayCashDeltaPerFrame, + totalMoney - DisplayCash); Sound.Play("cashup1.aud"); } - else if (DisplayCash > Cash) + else if (DisplayCash > totalMoney) { DisplayCash -= Math.Min(displayCashDeltaPerFrame, - DisplayCash - Cash); + DisplayCash - totalMoney); Sound.Play("cashdn1.aud"); } } diff --git a/OpenRa.Game/Traits/Harvester.cs b/OpenRa.Game/Traits/Harvester.cs index 5828e424b3..69edadd248 100644 --- a/OpenRa.Game/Traits/Harvester.cs +++ b/OpenRa.Game/Traits/Harvester.cs @@ -19,8 +19,8 @@ namespace OpenRa.Game.Traits public void Deliver(Actor self, Actor proc) { - proc.Owner.GiveCash(oreCarried * Rules.General.GoldValue); - proc.Owner.GiveCash(gemsCarried * Rules.General.GemValue); + proc.Owner.GiveOre(oreCarried * Rules.General.GoldValue); + proc.Owner.GiveOre(gemsCarried * Rules.General.GemValue); oreCarried = 0; gemsCarried = 0; }