Skip to content

Commit e2bebb5

Browse files
committed
fix: 🐛 fix GetScore()
it is suggested to turn score[] from int[] to long[]
1 parent ba479de commit e2bebb5

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

logic/Server/GameServer.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ private bool playerDeceased(int playerID) //这里需要判断大本营deceas
179179
game.GameMap.GameObjLockDict[GameObjType.Ship].EnterReadLock();
180180
try
181181
{
182-
foreach (Ship ship in game.GameMap.GameObjDict[GameObjType.Ship])
182+
foreach (Ship ship in game.GameMap.GameObjDict[GameObjType.Ship].Cast<Ship>())
183183
{
184-
if (ship.PlayerID == playerID && ship.PlayerState == PlayerStateType.Deceased) return true;
184+
if (ship.ShipID == playerID && ship.ShipState == ShipStateType.Deceased) return true;
185185
}
186186
}
187187
finally
@@ -192,22 +192,22 @@ private bool playerDeceased(int playerID) //这里需要判断大本营deceas
192192
return false;
193193
}
194194

195-
public override int[] GetScore()
195+
public override int[] GetMoney()
196196
{
197-
int[] score = new int[2]; // 0代表RedTeam,1代表BlueTeam
198-
game.GameMap.GameObjLockDict[GameObjType.Home].EnterReadLock();
199-
try
197+
int[] money = new int[2]; // 0代表RedTeam,1代表BlueTeam
198+
foreach (Team team in game.TeamList)
200199
{
201-
foreach (Home home in game.GameMap.GameObjDict[GameObjType.Home])
202-
{
203-
if (home.TeamID == 0) score[0] += (int)home.Score;
204-
else score[1] += (int)home.Score;
205-
}
206-
200+
money[(int)team.TeamID] = (int)game.GetTeamMoney(team.TeamID);
207201
}
208-
finally
202+
return money;
203+
}
204+
205+
public override int[] GetScore()
206+
{
207+
int[] score = new int[2]; // 0代表RedTeam,1代表BlueTeam
208+
foreach (Team team in game.TeamList)
209209
{
210-
game.GameMap.GameObjLockDict[GameObjType.Home].ExitReadLock();
210+
score[(int)team.TeamID] = (int)game.GetTeamScore(team.TeamID);
211211
}
212212
return score;
213213
}

logic/Server/ServerBase.cs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace Server
55
abstract class ServerBase : AvailableService.AvailableServiceBase
66
{
77
public abstract void WaitForEnd();
8+
public abstract int[] GetMoney();
89
public abstract int[] GetScore();
910
}
1011
}

0 commit comments

Comments
 (0)