public GameModel(int playerNumber) { Players = new Player[playerNumber]; List <CharacterRole> roleList = GameRules.GetCharacterRoles(playerNumber); roleList = (Utilities.Shuffle <CharacterRole>(roleList)); for (int i = 0; i < Players.Length; i++) { Players[i] = new Player(); Players[i].Type = (i == 0 ? PlayerType.Human : PlayerType.Computer); Players[i].Id = i; Players[i].Role = roleList[i]; Players[i].Name = GameRules.PlayerNames[i]; if (i != 0) { Players[i].Name += " (AI)"; } } Players = (Utilities.Shuffle <Player>(Players.ToList())).ToArray(); MissionTeamLengths = GameRules.GetMissionTeamLength(playerNumber); Missions = new Mission[MissionTeamLengths.Length]; for (int i = 0; i < Missions.Length; i++) { Missions[i] = new Mission(); } MissionNumber = MissionNumber.First; CurrentLeader = Players[0]; GamePhase = GamePhase.TeamPicking; }
private void AnimateCommand(BaseCommand command) { Write_ScrollView(command.LogConsole(GameModel)); Persistence.Save(GameModel, "Last.save"); if (command is PickTeamCommand) { foreach (Player player in GameModel.Players) { PlayerToController[player].PlayerVote = VoteType.Unknown; PlayerToController[player].IsPicked = ((PickTeamCommand)command).TeamPlayerIds.Contains(player.Id); } } if (command is EvaluateTeamVote) { foreach (Player player in GameModel.Players) { MissionNumber missNum = ((EvaluateTeamVote)command).MissionNumber; VoteNumber voteNum = ((EvaluateTeamVote)command).VoteNumber; Vote vote = GameModel.Missions[(int)missNum].Votes[(int)voteNum]; PlayerToController[player].PlayerVote = vote.VoteOfPlayer[player]; PlayerToController[player].IsLeader = GameModel.CurrentLeader == player; } } if (command is EvaluateMissionVote) { //Debug.Log("Not null missions: " + MissionControllers.Count(a => a != null)); //Debug.Log("CurrentMission is " + ((GameModel.CurrentMission == null) ? "null" : "not null")); MissionNumber missionNumber = ((EvaluateMissionVote)command).MissionNumber; Mission mission = GameModel.Missions[(int)missionNumber]; MissionControllers[(int)missionNumber].MissionResult = mission.MissionResult; } if (command is EvaluateGameResult) { UpdatePlayers(); } IOController.Refresh(); UpdateView(); }
public static BaseCommand CommandFromString(String strCommand, GameModel model) { if (strCommand.StartsWith("EvaluateGameResult ")) { String[] split = strCommand.Split(' '); MissionResult gameResult = (MissionResult)Int32.Parse(split[1]); DefeatType defeatType = (DefeatType)Int32.Parse(split[2]); EvaluateGameResult command = new EvaluateGameResult(); command.GameResult = gameResult; command.DefeatReason = defeatType; return(command); } if (strCommand.StartsWith("EvaluateMissionVote ")) { String[] split = strCommand.Split(' '); MissionNumber missionNumber = (MissionNumber)Int32.Parse(split[1]); EvaluateMissionVote command = new EvaluateMissionVote(missionNumber); return(command); } if (strCommand.StartsWith("EvaluateTeamVote ")) { String[] split = strCommand.Split(' '); MissionNumber missionNumber = (MissionNumber)Int32.Parse(split[1]); VoteNumber voteNumber = (VoteNumber)Int32.Parse(split[2]); EvaluateTeamVote command = new EvaluateTeamVote(missionNumber, voteNumber); return(command); } if (strCommand.StartsWith("PickTeam ")) { String[] split = strCommand.Split(' '); int leaderId = Int32.Parse(split[1]); string teamCode = split[2]; int playerNum = teamCode.Length; HashSet <int> playerTeamIds = new HashSet <int>(); for (int i = 0; i < teamCode.Length; i++) { if (teamCode[i] == '1') { playerTeamIds.Add(i); } } PickTeamCommand command = new PickTeamCommand(leaderId, playerTeamIds, playerNum); return(command); } if (strCommand.StartsWith("VoteMission ")) { String[] split = strCommand.Split(' '); int playerId = Int32.Parse(split[1]); MissionResult missionVote = (MissionResult)Int32.Parse(split[2]); VoteMissionCommand command = new VoteMissionCommand(playerId, missionVote); return(command); } if (strCommand.StartsWith("VoteTeam ")) { String[] split = strCommand.Split(' '); int playerId = Int32.Parse(split[1]); VoteType teamVote = (VoteType)Int32.Parse(split[2]); VoteTeamCommand command = new VoteTeamCommand(playerId, teamVote); return(command); } if (strCommand.StartsWith("ChangePlayer ")) { String[] split = strCommand.Split(' '); int playerId = Int32.Parse(split[1]); PlayerType playerType = (PlayerType)Int32.Parse(split[2]); String playerName = split[3]; ChangePlayerCommand command = new ChangePlayerCommand(playerId, playerType, playerName); return(command); } throw new ArgumentException("Command string not found: " + strCommand); }
public EvaluateMissionVote(MissionNumber missionNum) { MissionNumber = missionNum; }
public ActionResult <IEnumerable <MissionNumber> > Delete(MissionNumber missionnumber) { db.MissionNumbers.Remove(missionnumber); db.SaveChanges(); return(db.MissionNumbers.ToList()); }
public ActionResult <IEnumerable <MissionNumber> > Put([FromBody] MissionNumber missionnumber) { db.MissionNumbers.Update(missionnumber); db.SaveChanges(); return(db.MissionNumbers.ToList()); }
public EvaluateTeamVote(MissionNumber missNum, VoteNumber voteNum) { MissionNumber = missNum; VoteNumber = voteNum; }