コード例 #1
0
ファイル: KettleSession.cs プロジェクト: warmwine/SabberStone
 public void OnConcede(int entityid)
 {
     Console.WriteLine($"player[{entityid}] concedes");
     SabberStoneCore.Model.Entities.Controller concedingPlayer = Game.ControllerById(entityid);
     Game.Process(ConcedeTask.Any(concedingPlayer));
     SendPowerHistory(Game.PowerHistory.Last);
 }
コード例 #2
0
        public void OnConcede(int entityid)
        {
            Console.WriteLine($"player[{entityid}] concedes");
            var concedingPlayer = _game.ControllerById(entityid);

            _game.Process(ConcedeTask.Any(concedingPlayer));
            SendPowerHistory(_game.PowerHistory.Last);
        }
コード例 #3
0
        public static PlayerTask GetPlayerTask(Option option, Game g)
        {
            const bool SkipPrePhase = true;
            Controller c            = g.CurrentPlayer;

            switch (option.Type)
            {
            case Choose:
                return(ChooseTask.Pick(c, option.Choice));

            case Concede:
                return(ConcedeTask.Any(c));

            case EndTurn:
                return(EndTurnTask.Any(c));

            case HeroAttack:
                return(HeroAttackTask.Any(c, GetOpponentTarget(option.TargetPosition), SkipPrePhase));

            case Option.Types.PlayerTaskType.HeroPower:
                return(HeroPowerTask.Any(c, GetTarget(option.TargetPosition), option.SubOption, SkipPrePhase));

            case MinionAttack:
                return(MinionAttackTask.Any(c, c.BoardZone[option.SourcePosition - 1], GetOpponentTarget(option.TargetPosition), SkipPrePhase));

            case PlayCard:
                IPlayable source = c.HandZone[option.SourcePosition];
                if (source.Card.Type == CardType.MINION)
                {
                    return(PlayCardTask.Any(c, source, null, option.TargetPosition - 1, option.SubOption, SkipPrePhase));
                }
                else
                {
                    return(PlayCardTask.Any(c, source, GetTarget(option.TargetPosition),
                                            0, option.SubOption, SkipPrePhase));
                }

            default:
                throw new ArgumentOutOfRangeException();
            }

            ICharacter GetOpponentTarget(int position)
            {
                if (position == Option.OP_HERO_POSITION)
                {
                    return(c.Opponent.Hero);
                }
                return(c.Opponent.BoardZone[position - 9]);
            }

            ICharacter GetTarget(int position)
            {
                if (position == -1)
                {
                    return(null);
                }
                if (position >= Option.OP_HERO_POSITION)
                {
                    return(GetOpponentTarget(position));
                }
                if (position == Option.HERO_POSITION)
                {
                    return(c.Hero);
                }
                return(c.BoardZone[position - 1]);
            }
        }