private void GetPlayerCard(Dictionary <string, object> information) { var type = GameControllerHelper.ConvertObjToEnum <CurrentAction>(information["CurrentAction"]); GetCard(); Status = type; }
private void None(Dictionary <string, object> information) { if (information["CurrentAction"].ToString() == "StartGame") { if (players.Count == 0) { log.Error("Добавьте игроков в игру. Сейчас их " + players.Count); return; } if (!isGameEnded) { log.Info("Игра еще не закончилась"); return; } Status = CurrentAction.StartGame; additionaStatus = CurrentAction.None; if (information.ContainsKey("currentPlayer")) { var op = GameControllerHelper.ConvertObjToEnum <TypePlayer>(information["currentPlayer"]); if (op != players[currentPlayer].type) { currentPlayer = currentPlayer == 1 ? 0 : 1; } } else { Random rnd = new Random(); currentPlayer = rnd.Next(0, 2); } log.Info("Game is started. CurrentPlayer: " + currentPlayer); currentMove = 0; Dictionary <string, object> notify = new Dictionary <string, object>(); if (players[currentPlayer].type == TypePlayer.AI) { notify.Add("CurrentAction", CurrentAction.AIUseCardAnimation); } else { notify.Add("CurrentAction", CurrentAction.GetPlayerCard); } if (information.ContainsKey("CardTricksters")) { specialHand = (List <int>)information["CardTricksters"]; } SendGameNotification(notify); } }
public GameController(ILog _log, IArcoServer server = null) { MaxCard = 6; Status = CurrentAction.None; log = _log; LoseParams = GameControllerHelper.GetLoseParams(); WinParams = GameControllerHelper.GetWinParams(); players = new List <Player>(); if (server == null) { host = new ArcoServerClient(new BasicHttpBinding(), new EndpointAddress(url)); } else { host = server; } //Устанавливаем соответствие между методом и статусом eventHandlers = new Dictionary <CurrentAction, EventMethod>(); eventHandlers.Add(CurrentAction.None, None); eventHandlers.Add(CurrentAction.StartGame, StartGame); eventHandlers.Add(CurrentAction.GetPlayerCard, GetPlayerCard); eventHandlers.Add(CurrentAction.WaitHumanMove, WaitHumanMove); eventHandlers.Add(CurrentAction.PassStroke, PassStroke); eventHandlers.Add(CurrentAction.HumanUseCard, HumanUseCard); eventHandlers.Add(CurrentAction.UpdateStatHuman, UpdateStat); eventHandlers.Add(CurrentAction.UpdateStatAI, UpdateStat); eventHandlers.Add(CurrentAction.EndHumanMove, EndHumanMove); eventHandlers.Add(CurrentAction.AIMoveIsAnimated, AIMoveIsAnimated); eventHandlers.Add(CurrentAction.AIUseCardAnimation, AIUseCardAnimation); eventHandlers.Add(CurrentAction.EndAIMove, EndAIMove); eventHandlers.Add(CurrentAction.EndGame, EndGame); eventHandlers.Add(CurrentAction.PlayerMustDropCard, PlayerMustDropCard); specialCardHandlers = new Dictionary <int, Card>(); specialCardHandlers.Add(5, new Card5()); specialCardHandlers.Add(8, new Card8()); specialCardHandlers.Add(12, new Card12()); specialCardHandlers.Add(31, new Card31()); specialCardHandlers.Add(32, new Card32()); specialCardHandlers.Add(34, new Card34()); specialCardHandlers.Add(39, new Card39()); specialCardHandlers.Add(48, new Card48()); specialCardHandlers.Add(64, new Card64()); specialCardHandlers.Add(67, new Card67()); specialCardHandlers.Add(73, new Card73()); specialCardHandlers.Add(87, new Card87()); specialCardHandlers.Add(89, new Card89()); specialCardHandlers.Add(90, new Card90()); specialCardHandlers.Add(91, new Card91()); specialCardHandlers.Add(98, new Card98()); }
private void UpdateStat(Dictionary <string, object> information) { Winner = GameControllerHelper.CheckPlayerParams(players, WinParams, LoseParams); if (Winner.Length > 0) { Status = CurrentAction.EndGame; return; } if (information["CurrentAction"].ToString() == "EndHumanMove" || information["CurrentAction"].ToString() == "EndAIMove") { Status = information["CurrentAction"].ToString() == "EndHumanMove" ? CurrentAction.EndHumanMove : CurrentAction.EndAIMove; SendGameNotification(information); } }