Inheritance: MonoBehaviour
	public void OnExecuteAction ( object[] args )
	{
		if ( MyAction.Name == "Punch" )
		{
			SoundManager.Instance.PlayExecutePunchSound ();
		}
		else if ( MyAction.Name == "Slash" )
		{
			SoundManager.Instance.PlaySlashSound ();
		}
		else if ( MyAction.Name == "Super Slash" )
		{
			SoundManager.Instance.PlaySlash2Sound ();
		}
		else if ( MyAction.Name == "Hyper Slash" )
		{
			SoundManager.Instance.PlaySlash3Sound ();
		}

		ownerPlayer = args[0] as Player;
		MyAction = args[1] as PlayerAction;
		targetPlayer = args[2] as Player;

		this.transform.parent = ownerPlayer.SlashHotzone.transform;
		this.transform.localPosition = new Vector3 ();
		this.transform.localRotation = Quaternion.identity;
		this.transform.localScale = new Vector3 ( 1, 1, 1 );

		OnDoDamaged ( targetPlayer );
	}
        public override Node AdvanceHead(PlayerAction action)
        {
            Assert.That(action == PlayerAction.Raise || action == PlayerAction.Call);

            if (action == PlayerAction.Raise) return RaiseBranch;
            else return CheckBranch;
        }
	public GamepadInControlActionSet()
	{
		// Joystick
		Left = CreatePlayerAction("MoveLeft");
		Right = CreatePlayerAction("MoveRight");
		Up = CreatePlayerAction("MoveUp");
		Down = CreatePlayerAction("MoveDown");

		Movement = CreateTwoAxisPlayerAction(Left, Right, Down, Up);

		// Actions
		Jump = CreatePlayerAction("Jump");

		Break = CreatePlayerAction("Break");

		Dash = CreatePlayerAction("Dash");

		Accelerate = CreatePlayerAction("Accelerate");

		Desaccelerate = CreatePlayerAction("desaccelerate");


		// Menu
		Command = CreatePlayerAction("Command");
	}
Exemple #4
0
    public PlayerActions()
        : base()
    {
        L_Left = CreatePlayerAction("Left stick left");
        L_Right = CreatePlayerAction("Left stick right");
        L_Up = CreatePlayerAction("Left stick up");
        L_Down = CreatePlayerAction("Left stick down");

        R_Left = CreatePlayerAction("Right stick left");
        R_Right = CreatePlayerAction("Right stick right");
        R_Up = CreatePlayerAction("Right stick up");
        R_Down = CreatePlayerAction("Right stick down");

        Move = CreateTwoAxisPlayerAction(
            L_Left,
            L_Right,
            L_Down,
            L_Up);

        Look = CreateTwoAxisPlayerAction(
            R_Left,
            R_Right,
            R_Down,
            R_Up);

        Fire = CreatePlayerAction("Fire");
        Join = CreatePlayerAction("Join");
    }
 public PokerAction(PlayerMobile actor, PlayerAction action, PokerGameState state, int amountbet)
 {
     PlayerSerial = actor.Serial;
     Type = (int) action;
     State = (int) state;
     Amount = amountbet;
 }
 /// <summary>
 /// Gets the binding that is specific to the player action.
 /// </summary>
 /// <returns>The binding that is caused by the action.</returns>
 public static Binding GetBinding(PlayerAction action)
 {
     // using tryGetValue here to stop an incorrect index (throws an exception)
     Binding binding;
     binds.TryGetValue(action, out binding);
     return binding;
 }
        public override Node AdvanceHead(PlayerAction action)
        {
            Assert.That(action == PlayerAction.Call || action == PlayerAction.Fold);

            if (action == PlayerAction.Call) return CallBranch;
            else return null;
        }
	public bool PlayAction ( Player owner, PlayerAction action, Vector2 point0, Vector2 point1 )
	{
        if (action.Name == "Punch")
        {
            SoundManager.Instance.PlayExecutePunchSound();
        }
        else if (action.Name == "Slash")
        {
            SoundManager.Instance.PlaySlashSound();
        }
        else if (action.Name == "Super Slash")
        {
            SoundManager.Instance.PlaySlash2Sound();
        }
        else if (action.Name == "Hyper Slash")
        {
            SoundManager.Instance.PlaySlash3Sound();
        }

		var targets = Physics2D.OverlapAreaAll ( point0, point1, punchLayer.value );
		bool flag = false;
		foreach ( var target in targets )
		{
			var player = target.GetComponentInParent<Player> ();
			if ( player != null && player != owner )
			{
				flag |= ExecuteAction ( owner, action, player );
			}
		}
		if ( !flag )
		{
			ExecuteAction ( owner, action, null );
		}
		return flag;
	}
 /// <summary>
 /// Adds the specified keybind to the specified action.
 /// </summary>
 public static void AddKeybind(PlayerAction action, Binding bind)
 {
     if (binds.ContainsKey(action))
         binds[action] = bind;
     else
         binds.Add(action, bind);
 }
 protected InternalThreat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, StationLocation currentStation, PlayerAction actionType, ISittingDuck sittingDuck)
     : base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     CurrentStation = currentStation;
     sittingDuck.StationByLocation[currentStation].Threats.Add(this);
     ActionType = actionType;
 }
    public PlayerActions()
    {
        this.Skills = new PlayerAction[4];

        this.Shoot = this.CreatePlayerAction( "Shoot" );
        for (int i = 0; i < 4; i++)
        {
            this.Skills[i] = this.CreatePlayerAction( "Skill" + i );
        }

        this.YesOrOk = this.CreatePlayerAction( "Yes" );
        this.NoOrBack = this.CreatePlayerAction ( "No" );

        this.ILeft = this.CreatePlayerAction( "ILeft");
        this.IRight = this.CreatePlayerAction( "IRight");
        this.IUp = this.CreatePlayerAction( "IUp");
        this.IDown = this.CreatePlayerAction( "IDown");

        this.moveUp = this.CreatePlayerAction( "MoveUp" );
        this.moveDown = this.CreatePlayerAction( "MoveDown" );
        this.moveLeft = this.CreatePlayerAction( "MoveLeft" );
        this.moveRight = this.CreatePlayerAction( "MoveRight" );

        this.aimUp = this.CreatePlayerAction( "AimUp" );
        this.aimDown = this.CreatePlayerAction( "AimDown" );
        this.aimRight = this.CreatePlayerAction ( "AimRight" );
        this.aimLeft = this.CreatePlayerAction ( "AimLeft" );

        this.Movement = this.CreateTwoAxisPlayerAction(this.moveLeft, this.moveRight, this.moveDown, this.moveUp);
        this.Aim = this.CreateTwoAxisPlayerAction(this.aimLeft, this.aimRight, this.aimDown, this.aimUp);
    }
	public MonkActions(InputDevice device)
	{
		spawn0 = CreatePlayerAction ("Spawn0");
		spawn1 = CreatePlayerAction ("Spawn1");
		spawn2 = CreatePlayerAction ("Spawn2");
		spawn3 = CreatePlayerAction ("Spawn3");
		fireTurret = CreatePlayerAction ("FireTurret");
		moveUnitLeft = CreatePlayerAction ("MoveUnitLeft");
		moveUnitRight = CreatePlayerAction ("MoveUnitRight");
		moveHorizontal = CreateOneAxisPlayerAction (moveUnitLeft, moveUnitRight);

		moveUnitUp = CreatePlayerAction ("MoveUnitUp");
		moveUnitDown = CreatePlayerAction ("MoveUnitDown");
		moveVertical = CreateOneAxisPlayerAction (moveUnitDown,moveUnitUp);

		Device = device;

		spawn0.AddDefaultBinding (InputControlType.Action1);
		spawn1.AddDefaultBinding (InputControlType.Action2);
		spawn2.AddDefaultBinding (InputControlType.Action3);
		spawn3.AddDefaultBinding (InputControlType.Action4);
		fireTurret.AddDefaultBinding (InputControlType.RightTrigger);

		moveUnitLeft.AddDefaultBinding (InputControlType.LeftStickLeft);
		moveUnitRight.AddDefaultBinding (InputControlType.LeftStickRight);
		moveUnitUp.AddDefaultBinding (InputControlType.LeftStickUp);
		moveUnitDown.AddDefaultBinding (InputControlType.LeftStickDown);

	}
Exemple #13
0
    /** Checks whether the player was on beat or not **/
    protected void HandlePlayerTimings(PlayerAction playerAction)
    {
        // Only handles timings once per FixedUpdate
        if (timingsHandled)
        {
            return;
        }
        timingsHandled = true;

        TimingsManager.TimingResult result;
        List<int> triggers;
        bool debugWorthShowing = true;
        if (playerAction != PlayerAction.NONE)
        {
            result = timingsManager.checkAttempt(musicAudioSource.time, out triggers);
        }
        else
        {
            // User didn't make an attempt and had missed the timing window
            result = timingsManager.checkForMiss(musicAudioSource.time, out triggers);

            if (result == TimingsManager.TimingResult.NO_BEAT)
            {
                debugWorthShowing = false;
            }
        }

        if (showDebugTimingResults && debugWorthShowing)
        {
            Debug.Log("BaseChoreographer " + Time.time + ": " + result.ToString());
        }

        PlayerTimingResult(result, triggers, playerAction);
    }
 public void playerDid(PlayerAction pa)
 {
     handlePlayerDid(pa);
     updateState();
     if (Vector3.Distance(transform.position, playeractions.transform.position) < cosyProximity && !sceneFinished)
     {
         switch (state)
         {
             case DateState.HAPPY:
                 print("WE WIN!");
                 playeractions.Win();
                 sceneFinished = true;
                 StartCoroutine(WaitAndProgress(3));
                 break;
             case DateState.NORMAL:
                 Debug.Log("NOOOP");
                 transform.Translate(jumpAwayDistance, 0, 0);
                 break;
             case DateState.UNHAPPY:
                 print("WE LOSE!");
                 playeractions.Lose();
                 transform.Translate(0, 1000, 0);
                 break;
         }
     }
 }
 protected InternalThreat(ThreatType type, ThreatDifficulty difficulty, int health, int speed, int timeAppears, IList<StationLocation> currentStations, PlayerAction actionType, ISittingDuck sittingDuck)
     : base(type, difficulty, health, speed, timeAppears, sittingDuck)
 {
     CurrentStations = currentStations;
     foreach (var currentStation in CurrentStations)
         sittingDuck.StationByLocation[currentStation].Threats.Add(this);
     ActionType = actionType;
 }
 public PlayerActions()
 {
     Left = CreatePlayerAction( "Move Left" );
     Right = CreatePlayerAction( "Move Right" );
     Jump = CreatePlayerAction( "Jump" );
     Shift = CreatePlayerAction ("Kinetic Shift");
     Move = CreateOneAxisPlayerAction (Left, Right);
 }
        public static IndentedTextWriter GetGameLogWriterForIteration(PlayerAction[] playerActions, int gameCount)
        {
            string fileName = GetFileNameForType(playerActions, gameCount, "GameLog");

            if (fileName == null)
                return null;
            return new IndentedTextWriter(new System.IO.StreamWriter(fileName));
        }
 public ControlsActionSet()
 {
     Down = CreatePlayerAction ("Move Down");
     Left = CreatePlayerAction ("Move Left");
     Right = CreatePlayerAction ("Move Right");
     Up = CreatePlayerAction ("Move Up");
     Tap = CreatePlayerAction ("Tap");
 }
 public StrategyComparison(
     PlayerAction player1,
     PlayerAction player2,
     GameConfig gameConfig,
     bool rotateWhoStartsFirst,
     int numberOfGames)
     : this(new PlayerAction[] { player1, player2}, gameConfig, rotateWhoStartsFirst, numberOfGames)
 {
 }
Exemple #20
0
 private CourierPlayer()
 {
     Pedal               = CreatePlayerAction("Pedal");
     Brake				= CreatePlayerAction("Brake");
     SteeringColumnL     = CreatePlayerAction("SteeringColumnL");
     SteeringColumnR     = CreatePlayerAction("SteeringColumnR");
     SteeringColumnKeys  = CreateOneAxisPlayerAction(SteeringColumnL, SteeringColumnR);
     SteeringColumnGyro  = CreatePlayerAction("SteeringColumnGyro");
 }
Exemple #21
0
	public override void handlePlayerDid(PlayerAction pa) {
		switch(pa) {
			case PlayerAction.BACKOFF:
			case PlayerAction.MOVE_FORWARD:
				happyness -= loosingOnMove;
				happyness = Mathf.Max(0, happyness);
				break;
		}
	}
        public static float GetAccelerationIncrease(PlayerAction action)
        {
            if (action == PlayerAction.SpeedUp)
            {
                return GameData.ACCELERATION_INCREASE;
            }

            return action == PlayerAction.SpeedDown ? GameData.ACCELERATION_DECREASE : 0;
        }
        public static float GetAccelerationFactor(PlayerAction action, CarBehaviour carObj)
        {
            if (action == PlayerAction.SpeedUp)
            {
                return carObj.Speed < 0 ? 10 : 5;
            }

            return action == PlayerAction.SpeedDown ? (carObj.Speed < 0 ? 10 : 50) : 0;
        }
 public PeriscopeActions()
 {
     Periscope_TierUp = CreatePlayerAction("Periscope: Tier Up");
     Periscope_TierDown = CreatePlayerAction("Periscope: Tier Down");
     Periscope_RotateLeft = CreatePlayerAction("Periscope: Rotate Left");
     Periscope_RotateRight = CreatePlayerAction("Periscope: Rotate Right");
     //Periscope_Rotate = CreateOneAxisPlayerAction(Periscope_RotateLeft, Periscope_RotateRight);
     Periscope_CommitBearing = CreatePlayerAction("Periscope: Commit Bearing");
 }
 public PlayerActions()
 {
     attack = CreatePlayerAction("Attack");
     target = CreatePlayerAction("Target");
     right = CreatePlayerAction("Move Right");
     left = CreatePlayerAction("Move Left");
     up = CreatePlayerAction("Move Up");
     down = CreatePlayerAction("Move Down");
     move = CreateTwoAxisPlayerAction(left, right, down, up);
 }
Exemple #26
0
    private void FixedUpdate()
    {
        timingsHandled = false;
        HandleInput(storedPlayerAction);
        storedPlayerAction = PlayerAction.NONE;

        GameUpdate();
        HandlePlayerTimings(PlayerAction.NONE);
        BaseHandleTriggers();
    }
Exemple #27
0
    public PlayerActions()
    {
        Left = CreatePlayerAction( "Left" );
        Right = CreatePlayerAction( "Right" );
        Up = CreatePlayerAction( "Up" );
        Down = CreatePlayerAction( "Down" );

        Enter = CreatePlayerAction("Enter");
        Escape = CreatePlayerAction("Escape");
    }
Exemple #28
0
 public bool TryInvokeReaction(PlayerAction action, GameState state)
 {
     var reaction = _reactions[action];
     if (reaction.CanBeIvoked(state))
     {
         ReactionInvoked.Fire(this, () => new ReactionInvokedEventArgs{ReactionInvoked = reaction});
         reaction.Invoke(state);
         return true;
     }
     return false;
 }
	public void OnExecuteAction ( object[] args )
	{
		ownerPlayer = args[0] as Player;
		MyAction = args[1] as PlayerAction;
		targetPlayer = args[2] as Player;

		this.transform.position = ownerPlayer.transform.position;
		this.transform.localEulerAngles = new Vector3 ( 0, ownerPlayer.Lookleft ? -90 : 90, 0 );

		OnDoDamaged ( targetPlayer );
	}
 public StrategyComparison(
     PlayerAction[] playerActions,
     GameConfig gameConfig,
     bool rotateWhoStartsFirst,
     int numberOfGames)
 {
     this.playerActions = playerActions;
     this.gameConfig = gameConfig;
     this.rotateWhoStartsFirst = rotateWhoStartsFirst;
     this.numberOfGames = numberOfGames;
 }
 private static void HandlePlayerAction(object sender, PlayerActionEventArgs e)
 {
     action    = e.Action;
     PlayerBet = e.BetAmount;
 }
 /// <summary>
 /// Checks what type of bump occurs at the specified destination.
 /// </summary>
 /// <param name="playerState">player state, used to get current world position</param>
 /// <param name="playerAction">action indicating the direction player is trying to move</param>
 /// <param name="bumper">PlayerMove trying to bump / move, used to check if we can swap with another player with help intent.</param>
 /// <returns>the bump type which occurs at the specified point (BumpInteraction.None if it's open space)</returns>
 public static BumpType GetBumpTypeAt(PlayerState playerState, PlayerAction playerAction, PlayerMove bumper, bool isServer)
 {
     return(GetBumpTypeAt(playerState.WorldPosition.RoundToInt(), playerAction.Direction(), bumper, isServer));
 }
Exemple #33
0
 public static void PrintPlayerAction(IPlayer player, ICard cardPlayed, PlayerAction action)
 {
     PrintPlayerAction(player, cardPlayed, null, action);
 }
Exemple #34
0
        private static async Task ProcessShrine()
        {
            //check if current shrine was blacklisted by Combat Routine
            if (Blacklist.Contains(_shrine.Id))
            {
                GlobalLog.Error("[OpenChestTask] Current shrine was blacklisted from outside.");
                _shrine.Ignored = true;
                _shrine         = null;
                return;
            }

            var pos = _shrine.Position;

            if (Settings.ShrineOpenRange != -1)
            {
                if (pos.Distance > Settings.ShrineOpenRange * AbandonDistanceMult)
                {
                    GlobalLog.Debug("[OpenChestTask] Abandoning current shrine because its too far away.");
                    TemporaryIgnore(_shrine.Id);
                    _shrine = null;
                    return;
                }
            }

            if (pos.IsFar)
            {
                if (!pos.TryCome())
                {
                    GlobalLog.Error($"[OpenChestTask] Fail to move to {pos}. Marking this shrine as unwalkable.");
                    _shrine.Unwalkable = true;
                    _shrine            = null;
                }
                return;
            }
            var shrineObj = _shrine.Object as Shrine;

            if (shrineObj == null || shrineObj.IsDeactivated)
            {
                CombatAreaCache.Current.Shrines.Remove(_shrine);
                _shrine = null;
                return;
            }
            var attempts = ++_shrine.InteractionAttempts;

            if (attempts > MaxShrineAttempts)
            {
                GlobalLog.Error("[OpenChestTask] All attempts to take a shrine have been spent. Now ignoring it.");
                _shrine.Ignored = true;
                _shrine         = null;
                return;
            }
            if (await PlayerAction.Interact(shrineObj))
            {
                await Wait.LatencySleep();

                if (await Wait.For(() => shrineObj.IsDeactivated, "shrine deactivation", 100, 400))
                {
                    CombatAreaCache.Current.Shrines.Remove(_shrine);
                    _shrine = null;
                }
                return;
            }
            await Wait.SleepSafe(400);
        }
 public override void ReadFrom(IDataInputStream stream)
 {
     objID  = stream.ReadString();
     action = (PlayerAction)stream.ReadByte();
 }
        public void DoAction(PokerPlayer player, PlayerAction action, int bet = 0, bool isforced = false,
                             bool verbose = true)
        {
            if (!isforced && CurrentTurn != player)
            {
                return;
            }

            var    pm      = player.Owner;
            string message = string.Empty;

            Exporter.AddAction(pm, action, State, action == PlayerAction.AllIn ? player.Currency : bet);

            switch (action)
            {
            case PlayerAction.Bet:
                message = String.Format("I {0} {1}.", "bet", bet);

                MakeBet(player, bet);

                MinimumBet = bet;
                //raise after a bet is always 2*bet according to poker rules
                MinimumRaise = bet * 2;

                break;

            case PlayerAction.Raise:
                message = String.Format("I {0} {1}.",
                                        RoundActions.Exists(x => x == PlayerAction.Raise) ? "reraise" : "raise", bet);

                MakeBet(player, GetCallAmount(player) + bet);

                MinimumBet  += bet;
                MinimumRaise = bet;

                break;

            case PlayerAction.Call:
                message = "I call.";

                //match what is on the table from the last player. This takes into account how much you already have on the table in that round
                bet = GetCallAmount(player);

                MakeBet(player, bet);

                break;

            case PlayerAction.Check:

                message = "Check.";

                break;

            case PlayerAction.Fold:
                message = "I fold.";

                player.HasFolded = true;

                if (ActivePlayers.Count(x => !x.HasFolded) == 1)
                {
                    DoShowdown();
                    return;
                }

                break;

            case PlayerAction.AllIn:
                if (player.Currency > 0)
                {
                    message = MinimumBet > player.Currency ? "I call: all-in." : "All in.";

                    int difference = player.Currency + player.TotalBetInRound;

                    if (difference > MinimumBet)
                    {
                        MinimumBet = difference;
                    }

                    MakeBet(player, player.Currency);
                }

                break;
            }

            RefreshGumps();

            if (verbose)
            {
                PokerMessage(pm, message);
            }

            if (!isforced)
            {
                player.HasActed = true;
            }

            RoundActions.Add(action);

            if (!isforced && !CanEndBettingRound())
            {
                AssignNextTurn();
            }
        }
Exemple #37
0
 public AtualizarJogoApiRequest(int gameid, PlayerAction playeraction)
 {
     id           = gameid;
     key          = "54eac19e3f9543e1bdda45df80a117b9";
     Playeraction = playeraction;
 }
 public static bool IsModdedAction(PlayerAction action)
 {
     return(moddedActions.ContainsKey(action) || ephemeralActions.Contains(action));
 }
 internal static void RegisterAction(PlayerAction action, SRMod mod)
 {
     moddedActions.Add(action, mod);
 }
        public void CloseGameShouldNotPassAnyCard()
        {
            var playerAction = PlayerAction.CloseGame();

            Assert.Null(playerAction.Card);
        }
        public void CloseGameShouldPassCorrectActionType()
        {
            var playerAction = PlayerAction.CloseGame();

            Assert.Equal(PlayerActionType.CloseGame, playerAction.Type);
        }
        public void ChangeTrumpShouldNotPassAnyAnnounce()
        {
            var playerAction = PlayerAction.ChangeTrump();

            Assert.Equal(Announce.None, playerAction.Announce);
        }
Exemple #43
0
        public void CreateHtmlReport(IndentedTextWriter textWriter)
        {
            int          numberOfGamesToLog = 10;
            PlayerAction player1            = this.comparisonResults.comparison.playerActions[0];
            PlayerAction player2            = this.comparisonResults.comparison.playerActions[1];

            int maxTurn = this.comparisonResults.gameEndOnTurnHistogramData.GetXAxisValueCoveringUpTo(97);

            var htmlWriter = new HtmlRenderer(textWriter);

            htmlWriter.Begin();
            string game0Text = null;

            for (int gameIndex = 0; gameIndex < numberOfGamesToLog; ++gameIndex)
            {
                string currentGame = this.comparisonResults.comparison.GetHumanReadableGameLog(gameIndex);
                htmlWriter.InsertDataDiv("gamelog" + (gameIndex + 1), currentGame);
                if (gameIndex == 0)
                {
                    game0Text = currentGame;
                }
            }
            htmlWriter.Header1(player1.PlayerName + " VS " + player2.PlayerName);
            htmlWriter.WriteLine("Number of Games: " + this.comparisonResults.comparison.numberOfGames);
            htmlWriter.WriteLine(this.comparisonResults.comparison.firstPlayerAdvantage ? player1.PlayerName + " always started first" : "Players took turns going first");

            var pieLabels = new List <string>();
            var pieData   = new List <float>();

            for (int index = 0; index < this.comparisonResults.winnerCount.Length; ++index)
            {
                pieLabels.Add(this.comparisonResults.comparison.playerActions[index].name);
                pieData.Add((float)this.comparisonResults.PlayerWinPercent(index));
            }
            if (this.comparisonResults.tieCount > 0)
            {
                pieLabels.Add("Tie");
                pieData.Add((float)this.comparisonResults.TiePercent);
            }

            var statGatherer = this.comparisonResults.statGatherer;
            var gameConfig   = this.comparisonResults.comparison.gameConfig;
            var gameEndOnTurnHistogramData = this.comparisonResults.gameEndOnTurnHistogramData;

            htmlWriter.InsertExpander("Who Won?", delegate()
            {
                InsertPieChart(htmlWriter, "Game Breakdown", "Player", "Percent", pieLabels.ToArray(), pieData.ToArray(), colllapsebyDefault: false);
                InsertHistogram(htmlWriter, "Point Spread:  " + player1.PlayerName + " score <= 0 >= " + player2.PlayerName + " score", "Percentage", this.comparisonResults.pointSpreadHistogramData, int.MaxValue, content : delegate()
                {
                    htmlWriter.WriteLine("To the left of 0 are games won by " + player1.PlayerName + ".  To the right are games won by " + player2.PlayerName + ".  The xaxis (absolute value) indicates how many points the game was won by.  The area under the curve indicates the win rate for the corresponding player.");
                });
                InsertLineGraph(htmlWriter, "Probability player is ahead in points at end of round ", player1, player2, statGatherer.oddsOfBeingAheadOnRoundEnd, statGatherer.turnCounters, maxTurn);
                InsertLineGraph(htmlWriter, "Victory Point Total Per Turn", player1, player2, statGatherer.victoryPointTotal, statGatherer.turnCounters, maxTurn);
            }, collapseByDefault: false);
            htmlWriter.InsertExpander("Game Logs", delegate()
            {
                htmlWriter.InsertPaginationControl(numberOfGamesToLog);
                htmlWriter.Write("<textarea id='gameLogTextArea', rows='30' cols='100'>");
                htmlWriter.Write(game0Text);
                htmlWriter.WriteLine("</textarea>");
            });
            htmlWriter.InsertExpander("When does the game end?", delegate()
            {
                InsertHistogram(htmlWriter, "Probablity of Game ending on Turn", "Percentage", gameEndOnTurnHistogramData, maxTurn, colllapsebyDefault: false);
                InsertHistogramIntegrated(htmlWriter, "Probablity of Game being over by turn", "Percentage", gameEndOnTurnHistogramData, maxTurn);
            });
            htmlWriter.InsertExpander("Deck Strength", delegate()
            {
                InsertCardData(htmlWriter, statGatherer.endOfGameCardCount, gameConfig.cardGameSubset, player1, player2);
                InsertLineGraph(htmlWriter, "Coin To Spend Per Turn", player1, player2, statGatherer.coinToSpend, statGatherer.turnCounters, maxTurn, content : delegate()
                {
                    for (int i = 4; i < statGatherer.oddsOfHittingAtLeastACoinAmount.Length; ++i)
                    {
                        InsertLineGraph(htmlWriter, "Odds of Hitting at Least " + i + " coin", player1, player2, statGatherer.oddsOfHittingAtLeastACoinAmount[i], statGatherer.turnCounters, maxTurn);
                    }
                });
                InsertLineGraph(htmlWriter, "Number of cards Gained Per Turn", player1, player2, statGatherer.cardsGained, statGatherer.turnCounters, maxTurn);
                htmlWriter.InsertExpander(player1.PlayerName, delegate()
                {
                    InsertCardData(htmlWriter, "Total Count Of Card", gameConfig.cardGameSubset, statGatherer.cardsTotalCount, statGatherer.turnCounters, 0, maxTurn);
                    InsertCardData(htmlWriter, "Gain Of Card", gameConfig.cardGameSubset, statGatherer.carsGainedOnTurn, statGatherer.turnCounters, 0, maxTurn);
                });
                htmlWriter.InsertExpander(player2.PlayerName, delegate()
                {
                    InsertCardData(htmlWriter, "Total Count Of Card", gameConfig.cardGameSubset, statGatherer.cardsTotalCount, statGatherer.turnCounters, 1, maxTurn);
                    InsertCardData(htmlWriter, "Gain Of Card", gameConfig.cardGameSubset, statGatherer.carsGainedOnTurn, statGatherer.turnCounters, 1, maxTurn);
                });
                InsertLineGraph(htmlWriter, "Shuffles Per Turn", player1, player2, statGatherer.deckShuffleCount, statGatherer.turnCounters, maxTurn);

                InsertLineGraph(htmlWriter, "Ruins Gained Per Turn", player1, player2, statGatherer.ruinsGained, statGatherer.turnCounters, maxTurn);
                InsertLineGraph(htmlWriter, "Curses Gained Per Turn", player1, player2, statGatherer.cursesGained, statGatherer.turnCounters, maxTurn);
                InsertLineGraph(htmlWriter, "Curses Trashed Per Turn", player1, player2, statGatherer.cursesTrashed, statGatherer.turnCounters, maxTurn);
            });

            htmlWriter.InsertExpander("Individual Card Graphs", delegate()
            {
                foreach (Card card in gameConfig.cardGameSubset.OrderBy(c => c.DefaultCoinCost))
                {
                    if (statGatherer.cardsTotalCount[card].forwardTotal.HasNonZeroData ||
                        statGatherer.carsGainedOnTurn[card].forwardTotal.HasNonZeroData)
                    {
                        htmlWriter.InsertExpander(card.name, delegate()
                        {
                            InsertLineGraph(htmlWriter, "Card Total At Turn", player1, player2, statGatherer.cardsTotalCount[card], statGatherer.turnCounters, maxTurn, colllapsebyDefault: false);
                            InsertLineGraph(htmlWriter, "Card Gained At Turn", player1, player2, statGatherer.carsGainedOnTurn[card], statGatherer.turnCounters, maxTurn, colllapsebyDefault: true);
                        });
                    }
                }
            });

            htmlWriter.End();
        }
Exemple #44
0
 // Use this for initialization
 void Start()
 {
     pAct = GameObject.Find("Player").GetComponent <PlayerAction>();
 }
    // The main function used to resolve a round of combat
    public void TakeRound()
    {
        CUI.DisplayLine("");

        // Apply defense modifiers first
        if (player_action == PlayerAction.Defend)
        {
            Player.ModifyDefense(4);
        }

        if (dragon_action == DragonAction.Defend)
        {
            Player.ModifyDefense(4);
        }

        // If Player Speed > Enemy Speed and Dragon Speed, Player goes first
        if (Player.GetSpeed() >= Enemy.GetSpeed() && Player.GetSpeed() >= Dragon.GetSpeed())
        {
            PlayerTurn();

            // If Enemy not dead
            if (!Enemy.IsDead())
            {
                //if a dragon exists and is not dead, it gets a turn
                if (Dragon != null && !Dragon.IsDead())
                {
                    //if it's faster than the enemy
                    if (Dragon.GetSpeed() >= Enemy.GetSpeed())
                    {
                        DragonTurn();
                        // If Enemy still not dead and not caputured
                        if (!Enemy.IsDead() || !captured)
                        {
                            EnemyTurn();
                        }
                    }
                    //else if enemy is faster than dragon
                    else
                    {
                        // If Enemy still not dead and not caputured
                        if (!Enemy.IsDead() || !captured)
                        {
                            EnemyTurn();
                        }
                        //if dragon is not dead, dragon's turn
                        if (!Dragon.IsDead())
                        {
                            DragonTurn();
                        }
                    }
                }
                //else if no usable dragonn
                else
                {
                    // If Enemy still not dead and not caputured
                    if (!Enemy.IsDead() || !captured)
                    {
                        EnemyTurn();
                    }
                }
            }
        }
        //Else if dragon is fastest
        else if (Dragon != null && !Dragon.IsDead() && Dragon.GetSpeed() >= Enemy.GetSpeed())
        {
            DragonTurn();

            // If Enemy not dead and player not dead
            if (!Enemy.IsDead() && !Player.IsDead())
            {
                //if player's faster than the enemy
                if (Player.GetSpeed() >= Enemy.GetSpeed())
                {
                    PlayerTurn();
                    // If Enemy still not dead and not caputured
                    if (!Enemy.IsDead() || !captured)
                    {
                        EnemyTurn();
                    }
                }
                //else if enemy is faster than player
                else
                {
                    // If Enemy still not dead and not caputured
                    if (!Enemy.IsDead() || !captured)
                    {
                        EnemyTurn();
                    }
                    //if player is not dead, player's turn
                    if (!Player.IsDead())
                    {
                        PlayerTurn();
                    }
                }
            }
        }
        //Else if enemy is fastest
        else
        {
            EnemyTurn();
            //If Player not dead
            if (!Player.IsDead())
            {
                //if a dragon exists and is not dead, it gets a turn
                if (Dragon != null && !Dragon.IsDead())
                {
                    //if dragon's faster than the player
                    if (Dragon.GetSpeed() >= Player.GetSpeed())
                    {
                        DragonTurn();
                        //if enemy and player not dead, player's turn
                        if (!Enemy.IsDead() && !Player.IsDead())
                        {
                            PlayerTurn();
                        }
                    }
                    //else if player is faster than dragon
                    else
                    {
                        PlayerTurn();
                        //if dragon is not dead and enemy is not caputured or dead, dragon's turn
                        if (!Dragon.IsDead() && !Enemy.IsDead() && !captured)
                        {
                            DragonTurn();
                        }
                    }
                }
                //else if no usable dragonn
                else
                {
                    PlayerTurn();
                }
            }
        }

        // Reset variables at the end of the round
        player_action = PlayerAction.None;
        dragon_action = DragonAction.None;
        item          = string.Empty;
        SuccessUse    = false;

        // Reset any modifiers that occurred this round
        Player.ResetStats();
        Dragon.ResetStats();
        Enemy.ResetStats();

        // Reset queue status
        CUI.ResetQueue();

        CUI.UpdateSliders(Player.GetCurrentHealth(), Dragon.GetCurrentHealth(), Dragon.GetCurrentMana(), Enemy.GetCurrentHealth());

        // If Player dead
        if (Player.IsDead() || Player.AllDragonsDead())
        {
            // Game over
            CUI.DisplayLine("Game over");
            CUI.Wait();
        }

        // If Dragon dead
        if (Dragon.IsDead())
        {
            GameObject.Find("Dragon").GetComponent <SpriteRenderer>().enabled = false;
            //if the player has dragons left with > 0 HP, send one out
            if (!Player.AllDragonsDead())
            {
                CUI.SendOutDragon();
            }
        }

        // If Enemy dead
        if (Enemy.IsDead())
        {
            // Award experience and gold
            //float gold = Enemy.GetGold();
            float gold = Random.Range(1, 25);
            float exp  = 100;

            InventoryCanvasController.instance.InsertReward();

            Player.AddGold(gold);
            Player.GainExperience(100);
            Dragon.GainExperience(100);

            CUI.DisplayLine("");
            CUI.DisplayLine("Enemy defeated!");
            CUI.DisplayLine("Gained " + gold.ToString() + " gold!");
            CUI.DisplayLine("Gained " + exp.ToString() + " XP!");
            CUI.DisplayLine("Press any key to continue...");

            CUI.Wait();
        }

        RoundCounter++;
    }
 public DisqualifiedStateChange(int player, PlayerAction action) : base(StateAction.Disqualified, player, CamelColor.Blue, -1)
 {
     PlayerAction = action;
 }
Exemple #47
0
 public void UpdateObservers(PlayerAction action)
 {
     observers.ForEach(observer => observer.update(action));
 }
    /// <summary>
    /// Updates the players behaviour.
    /// </summary>
    protected override void FixedUpdate()
    {
        var pos = (Vector2)transform.position + coll.offset;

        if (action == PlayerAction.None)
        {
            if (playerInput.dash && dashPausePos == 0)
            {
                dashPos = 0;
                action  = PlayerAction.Dash;
            }
        }

        if (action == PlayerAction.None || action == PlayerAction.Dash)
        {
            // Handle dash
            if (action == PlayerAction.Dash)
            {
                if (dashPos < dashLength)
                {
                    speed = dashSpeed;
                    dashPos++;
                }
                else
                {
                    dashPausePos = dashPause;
                    speed        = walkSpeed;
                    action       = PlayerAction.None;
                }
            }

            if (dashPausePos > 0)
            {
                dashPausePos--;
            }

            // Check so we're not moving against a collider on the x axis
            if (playerInput.x != 0)
            {
                coll.enabled = false;
                var xHits = Physics2D.RaycastAll(pos, new Vector2(playerInput.x, 0), 0.47f);
                coll.enabled = true;

                foreach (var hit in xHits)
                {
                    if (hit.collider != null && !hit.collider.isTrigger)
                    {
                        playerInput.x = 0;
                        break;
                    }
                }
            }
            // Check so we're not moving against a collider on the y axis
            if (playerInput.y != 0)
            {
                coll.enabled = false;
                var yHits = Physics2D.RaycastAll(pos, new Vector2(0, playerInput.y), 0.47f);
                coll.enabled = true;

                foreach (var hit in yHits)
                {
                    if (hit.collider != null && !hit.collider.isTrigger)
                    {
                        playerInput.y = 0;
                        break;
                    }
                }
            }

            // Make sure we normalize movement
            //var move = new Vector2 (playerInput.x, playerInput.y);

            var move = new Vector2(Joystick.x, Joystick.y);

            if (move.magnitude > 1)
            {
                move.Normalize();
            }

            // Make some dust
            if (move != Vector2.zero)
            {
                if (dustPause <= 0)
                {
                    Instantiate(dust, new Vector3(transform.position.x, transform.position.y - 0.4375f, 0), Quaternion.identity);
                    dustPause = 1.5f;
                }
                else
                {
                    dustPause -= 4 * Time.fixedDeltaTime;
                }
            }
            else
            {
                dustPause = 0;
            }

            Move(move);
        }

        base.FixedUpdate();
    }
Exemple #49
0
 public void MakeMove(PlayerAction playerAction)
 {
 }
 public SpaceVillainArcadePlayerActionMessage(PlayerAction playerAction)
 {
     PlayerAction = playerAction;
 }
Exemple #51
0
        public static void PrintPlayerAction(IPlayer player, ICard cardPlayed, List <ICard> cardsExtra, PlayerAction action)
        {
            switch (action)
            {
            case PlayerAction.Have:
                Console.WriteLine(string.Format("Player {0} currently holds the following cards:", player.PlayerFigure.FigureName));
                foreach (ICard cardHeld in player.CardsHeld)
                {
                    Console.WriteLine(string.Format("Card : {0} {1} {2}", cardHeld.CardSuit, cardHeld.CardRank, cardHeld.CardFunc));
                }
                break;

            case PlayerAction.Play:
                Console.WriteLine(string.Format("Player {0} just played the following card:", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Card : {0} {1} {2}", cardPlayed.CardSuit, cardPlayed.CardRank, cardPlayed.CardFunc));
                break;

            case PlayerAction.NoResponse:
                Console.WriteLine(string.Format("Player {0} did not respond to the original card", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.NoResponseFromAll:
                Console.WriteLine(string.Format("No player respond to the original card", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.Judge:
                Console.WriteLine(string.Format("The central card deck just used the following card to judge for Player {0}:", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Card : {0} {1} {2}", cardPlayed.CardSuit, cardPlayed.CardRank, cardPlayed.CardFunc));
                break;

            case PlayerAction.Counter:
                Console.WriteLine(string.Format("Player {0} just played the following card to counter:", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Card : {0} {1} {2}", cardPlayed.CardSuit, cardPlayed.CardRank, cardPlayed.CardFunc));
                break;

            case PlayerAction.Deployed:
                Console.WriteLine(string.Format("The following card just gets deployed on Player {0}:", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Card : {0} {1} {2}", cardPlayed.CardSuit, cardPlayed.CardRank, cardPlayed.CardFunc));
                break;

            case PlayerAction.Annulled:
                Console.WriteLine(string.Format("The following original card just gets annulled:", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Card : {0} {1} {2}", cardPlayed.CardSuit, cardPlayed.CardRank, cardPlayed.CardFunc));
                break;

            case PlayerAction.Drawn:
                Console.WriteLine(string.Format("The central card deck just deals the following cards to Player {0}:", player.PlayerFigure.FigureName));
                foreach (ICard cardExtra in cardsExtra)
                {
                    Console.WriteLine(string.Format("Card : {0} {1} {2}", cardExtra.CardSuit, cardExtra.CardRank, cardExtra.CardFunc));
                }
                break;

            case PlayerAction.PrisonTakeEffect:
                Console.WriteLine(string.Format("Prison on Player {0} takes effect", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Player {0} cannot play any card due to being in prison", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.PrisonNotTakeEffect:
                Console.WriteLine(string.Format("Prison on Player {0} does not take effect", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Prison on Player {0} disappears", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.BombTakeEffect:
                Console.WriteLine(string.Format("Bomb on Player {0} takes effect", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Player {0} takes damage as the bomb just exploded", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.BombNotTakeEffect:
                Console.WriteLine(string.Format("Bomb on Player {0} does not take effect", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Bomb on Player {0} passes to the next player", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.JadeTakeEffect:
                Console.WriteLine(string.Format("Jade for Player {0} takes effect", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Player {0} does not respond further", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.JadeNotTakeEffect:
                Console.WriteLine(string.Format("Jade for Player {0} does not take effect", player.PlayerFigure.FigureName));
                Console.WriteLine(string.Format("Player {0} needs to play a dodge card or will take damage", player.PlayerFigure.FigureName));
                break;

            case PlayerAction.TakeDamage:
                Console.WriteLine(string.Format("Player {0} just takes some damage", player.PlayerFigure.FigureName)); // TODO How much damage
                break;

            case PlayerAction.RemainingHitpoint:
                Console.WriteLine(string.Format("Hitpoint of Player {0} is {1}", player.PlayerFigure.FigureName, player.PlayerFigure.HitPoint));
                break;

            default:
                throw new NotImplementedException("Unknown player action");
            }
        }
Exemple #52
0
 public override PlayerAction GetTurn(GetTurnContext context)
 {
     return(PlayerAction.Fold());
 }
Exemple #53
0
 public WalledVillage(PlayerAction playerAction)
 {
     this.playerAction = playerAction;
 }
            /// <summary>
            /// Called by the SpaceVillainArcadeComponent when Userinput is received.
            /// </summary>
            /// <param name="action">The action the user picked.</param>
            public void ExecutePlayerAction(PlayerAction action)
            {
                if (!_running)
                {
                    return;
                }

                switch (action)
                {
                case PlayerAction.Attack:
                    var attackAmount = _random.Next(2, 6);
                    _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message",
                                                               ("enemyName", _enemyName),
                                                               ("attackAmount", attackAmount));
                    SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerAttackSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f));
                    if (!_owner._enemyInvincibilityFlag)
                    {
                        _enemyHp -= attackAmount;
                    }
                    _turtleTracker -= _turtleTracker > 0 ? 1 : 0;
                    break;

                case PlayerAction.Heal:
                    var pointAmount = _random.Next(1, 3);
                    var healAmount  = _random.Next(6, 8);
                    _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message",
                                                               ("magicPointAmount", pointAmount),
                                                               ("healAmount", healAmount));
                    SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerHealSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f));
                    if (!_owner._playerInvincibilityFlag)
                    {
                        _playerMp -= pointAmount;
                    }
                    _playerHp += healAmount;
                    _turtleTracker++;
                    break;

                case PlayerAction.Recharge:
                    var chargeAmount = _random.Next(4, 7);
                    _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message", ("regainedPoints", chargeAmount));
                    SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerChargeSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f));
                    _playerMp      += chargeAmount;
                    _turtleTracker -= _turtleTracker > 0 ? 1 : 0;
                    break;
                }

                if (!CheckGameConditions())
                {
                    return;
                }

                ValidateVars();
                ExecuteAiAction();

                if (!CheckGameConditions())
                {
                    return;
                }
                ValidateVars();
                UpdateUi();
            }
        public override void DoAction(int player, PlayerAction action)
        {
            if (player != playerNum)
            {
                return;
            }

            if (state == LocalState.WaitForButton)
            {
                if (action == PlayerAction.JoystickButton)
                {
                    game.Sound.PlayBeep(playerNum);
                    state = LocalState.ZoomInStore;
                    stateTimer.Change(10, 10);
                    game.Players[playerNum].Highlight = false;
                }
            }
            else if (
                state == LocalState.InStore ||
                state == LocalState.Outside)
            {
                switch (action)
                {
                case PlayerAction.JoystickButton:
                    if (state == LocalState.Outside)
                    {
                        Plot plot =
                            game.Map.CheckHouse(
                                playerNum,
                                new Rectangle(
                                    playerSprite.X,
                                    playerSprite.Y,
                                    Graphics.SMALLPLAYERWIDTH,
                                    Graphics.SMALLPLAYERHEIGHT
                                    ));

                        if (plot != null)
                        {
                            game.Sound.PlayBeep(playerNum);
                        }
                    }
                    break;

                case PlayerAction.JoystickCenter:
                    playerSprite.StopAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.S);
                    playerIncX = 0;
                    playerIncY = 0;
                    break;

                case PlayerAction.JoystickN:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.N);
                    playerIncX = 0;
                    playerIncY = -1;
                    break;

                case PlayerAction.JoystickNE:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.NE);
                    playerIncX = 1;
                    playerIncY = -1;
                    break;

                case PlayerAction.JoystickE:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.E);
                    playerIncX = 1;
                    playerIncY = 0;
                    break;

                case PlayerAction.JoystickSE:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.SE);
                    playerIncX = 1;
                    playerIncY = 1;
                    break;

                case PlayerAction.JoystickS:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.S);
                    playerIncX = 0;
                    playerIncY = 1;
                    break;

                case PlayerAction.JoystickSW:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.SW);
                    playerIncX = -1;
                    playerIncY = 1;
                    break;

                case PlayerAction.JoystickW:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.W);
                    playerIncX = -1;
                    playerIncY = 0;
                    break;

                case PlayerAction.JoystickNW:
                    playerSprite.StartAnimation();
                    playerSprite.ChangeDirection(SpriteDirection.NW);
                    playerIncX = -1;
                    playerIncY = -1;
                    break;
                }
            }
        }
Exemple #56
0
        private static void InsertCardData(HtmlRenderer htmlWriter, MapOfCardsForGameSubset <PlayerCounterSeparatedByGame> map, CardGameSubset gameSubset, PlayerAction player1, PlayerAction player2)
        {
            var cards       = gameSubset.OrderBy(c => c.DefaultCoinCost);
            var player1Data = new List <float>();
            var player2Data = new List <float>();

            foreach (Card card in cards)
            {
                player1Data.Add(map[card].GetAverage(playerIndex: 0));
                player2Data.Add(map[card].GetAverage(playerIndex: 1));
            }

            htmlWriter.InsertExpander("Cards Report", delegate()
            {
                htmlWriter.InsertColumnChart(
                    "Average Count of Cards Owned at End of Game",
                    "Card",
                    new string[] { player1.name, player2.name },
                    cards.Select(c => c.name).ToArray(),
                    new float[][] { player1Data.ToArray(), player2Data.ToArray() });
            }, collapseByDefault: false);
        }
Exemple #57
0
        public async Task ExecuteTurnPhaseAsync()
        {
            _gameStateNotifier.NotifyTurnPhaseExecuting(_gameState.CurrentPlayer.PlayerId, _gameState.CurrentPhase);
            switch (_gameState.CurrentPhase)
            {
            case TurnPhase.TurnStart:
                _gameState.CurrentPhase = TurnPhase.PlayerAction;
                break;

            case TurnPhase.PlayerAction:
                var playerAction = await _gameState.CurrentPlayer.GetPlayerActionAsync();

                var gameAction = await _gameActionResolver.GetGameActionAsync(playerAction);

                var playedCards = await Task.WhenAll(playerAction.CardIds.Select(id => _cardResolver.GetCardAsync(id)));

                await gameAction.ExecuteActionAsync(_gameState.CurrentPlayer.PlayerId, _gameState, new ActionCost(playedCards));

                _gameStateNotifier.NotifyPlayersChanged(_gameState.Players.Select(p => p.GetState()));
                break;

            case TurnPhase.TurnEnd:
                _gameState.GoToNextPlayer();
                _gameState.CurrentPhase = TurnPhase.TurnStart;
                break;

            case TurnPhase.Elimination:
                var loseCard = _gameState.CurrentPlayer.Cards.LastOrDefault(c => c.Family == CardFamily.Lose);
                if (loseCard is null)
                {
                    _gameState.CurrentPhase = TurnPhase.TurnEnd;
                    break;
                }

                var extraLifeCard = _gameState.CurrentPlayer.Cards.FirstOrDefault(c => c.Family == CardFamily.ExtraLife);
                if (extraLifeCard is null)
                {
                    _gameState.CurrentPlayer.IsEliminated = true;
                }
                else
                {
                    var action = await _gameActionResolver.GetGameActionAsync(PlayerAction.PlayCard(_gameState.CurrentPlayer.PlayerId, extraLifeCard.CardId));

                    await action.ExecuteActionAsync(_gameState.CurrentPlayer.PlayerId, _gameState, new ActionCost(new List <ICard> {
                        extraLifeCard, loseCard
                    }));
                }
                _gameStateNotifier.NotifyPlayersChanged(_gameState.Players.Select(p => p.GetState()));

                if (_gameState.Players.Count(c => !c.IsEliminated) == 1)
                {
                    _gameState.CurrentPhase = TurnPhase.GameEnd;
                    break;
                }

                _gameState.CurrentPhase = TurnPhase.TurnEnd;
                break;

            default:
                _gameStateNotifier.NotifyEndGameCondition(_gameState.Players.Single(c => !c.IsEliminated).PlayerId);
                return;
            }

            await ExecuteTurnPhaseAsync();
        }
        public void ChangeTrumpShouldNotPassAnyCard()
        {
            var playerAction = PlayerAction.ChangeTrump();

            Assert.Null(playerAction.Card);
        }
        public void CloseGameShouldNotPassAnyAnnounce()
        {
            var playerAction = PlayerAction.CloseGame();

            Assert.Equal(Announce.None, playerAction.Announce);
        }
Exemple #60
0
 protected virtual void StartTurn()
 {
     currentAction = PlayerAction.None;
 }