Example #1
0
 public GameLogic(Store store)
 {
     Store       = store;
     Server      = new Server();
     ActionLogic = new ActionLogic(Store);
     PlayerLogic = new PlayerLogic(Store);
 }
Example #2
0
        public List <string> DoAction(string usernameFrom, string action)
        {
            lock (doActionLock)
            {
                List <string> ret = new List <string>();

                Player player = GetLoggedPlayer(usernameFrom);
                if (!player.IsAlive)
                {
                    throw new LoggedPlayerIsDeadException();
                }
                if (!Store.ActiveGame.isOn)
                {
                    ret.Add("FINISHED");
                    ret.Add(ActiveGameResult.ToUpper());
                    return(ret);
                }
                else
                {
                    try
                    {
                        ret = ret.Concat(ActionLogic.DoAction(player, action)).ToList();
                        List <string> ended = CheckIfGameHasEnded();
                        if (ended != null)
                        {
                            ret = ret.Concat(ended).ToList();
                        }
                    }
                    catch (WaitForTurnException)
                    {
                        List <string> ended = CheckIfGameHasEnded();
                        if (ended != null)
                        {
                            ret = ret.Concat(ended).ToList();
                        }
                        else
                        {
                            throw new WaitForTurnException();
                        }
                    }
                    return(ret);
                }
            }
        }