/// <summary> /// LP_BattlefieldTeamChanged - 0x165 /// </summary> /// <returns></returns> private COutPacket TeamChanged(int dwCharId, BattlefieldData.BattlefieldTeams nTeam) { var p = new COutPacket(SendOps.LP_BattlefieldTeamChanged); p.Encode4(dwCharId); p.Encode1(nTeam); return(p); }
private void WarpTeamToMap(BattlefieldData.BattlefieldTeams nTeam, int nMapId) { foreach (var player in aTeams) { if (player.Value != nTeam || Users[player.Key] is null) { continue; } var user = Users[player.Key]; user.Action.SetField(nMapId); } }
private void ChangePlayerTeam(int dwUserId, BattlefieldData.BattlefieldTeams nTeam) { if (!aTeams.ContainsKey(dwUserId)) { aTeams.Add(dwUserId, nTeam); } else if (aTeams.ContainsKey(dwUserId) && aTeams[dwUserId] != nTeam) { aTeams[dwUserId] = nTeam; } else { return; // already in the team } Broadcast(TeamChanged(dwUserId, nTeam)); }
/// <summary> /// Updates score of the given team by the given amount and returns if the score has reached zero. /// </summary> /// <param name="nTeam">Team to modify score of</param> /// <param name="nAmount">Amount to modify score by. Score is modified additively. Can be a positive or negative value.</param> /// <returns>True if a score has reached zero and the game should end, else false.</returns> private void UpdateScore(BattlefieldData.BattlefieldTeams nTeam, int nAmount) { if (nAmount != 0) { if (nTeam == BattlefieldData.BattlefieldTeams.Wolves) { WolfScore += nAmount; } else { SheepScore += nAmount; } Broadcast(ScoreUpdate(WolfScore, SheepScore)); } if (SheepScore <= 0 || WolfScore <= 0) { OnTeamWin(SheepScore <= 0); BroadcastNotice($"Congratualations {(SheepScore <= 0 ? "wolves" : "sheep")} on your victory!"); } }