예제 #1
0
        public override List <SwapChoices> GetSwapMoves(PlayerSeat seat)
        {
            List <JewelID> prefJewels = new List <JewelID>()
            {
                JewelID.wrath
            };

            // Look through all of the current mohe's abilities
            IRuntimeMoheData mohe = GameController.Instance.GetPlayerController(seat).Player.Roster.CurrentMohe();

            // If there are any abilities that are uncharged, add to abilities buffer
            foreach (var abl in mohe.Abilities)
            {
                foreach (var comp in abl.AbilityComponents)
                {
                    if (comp.Has < comp.Needs && !prefJewels.Contains(comp.JewelType))
                    {
                        prefJewels.Add(comp.JewelType);
                    }
                }
            }

            // look for matches
            List <SwapChoices> matchesBuff = FindMatchesUtil.FindBestMatches(game.GameBoard.GetBoardData().GetMap(), prefJewels);

            return(matchesBuff.OrderByDescending(m => m.matches).ToList());
        }
예제 #2
0
            public void UpdatePlayerIndex10TimesFrom0()
            {
                var player  = (Player)A.Player().WithSeat(PlayerSeat.Left);
                var player1 = (Player)A.Player().WithSeat(PlayerSeat.Right);
                var players = new List <IPlayer> {
                    player, player1
                };
                var token        = (ProcessTurn)A.Token().WithPlayers(players);
                var quantPlayers = players.Count;

                const PlayerSeat firstSeat = PlayerSeat.Left;

                token.SetCurrentSeat(firstSeat);
                token.SetStarterSeat(firstSeat);

                const int n = 10;

                //Update the index n times
                for (var i = 0; i < n; i++)
                {
                    token.UpdateCurrentPlayer();
                }

                //turn count has to be the same as n
                Assert.AreEqual(token.TurnCount, n);
                //+1 because we don't update the index on the first attempt
                var turnMod = n + 1 % quantPlayers;

                Assert.AreEqual(PlayerSeat.Right, token.CurrentPlayerSeat);
            }
예제 #3
0
        public Player(PlayerSeat seat, TeamData teamData = null, LibraryData deckData = null,
                      Configurations configurations      = null)
        {
            Configurations = configurations;
            Seat           = seat;
            Hand           = new Collection <IRuntimeCard>();

            if (teamData != null)
            {
                Team = new Team(this, teamData);
            }

            if (deckData != null)
            {
                Library = new Library(this, deckData, configurations);
            }

            Graveyard = new Graveyard(this);

            #region Mechanics

            DrawMechanics       = new DrawMechanics(this);
            DiscardMechanics    = new DiscardMechanics(this);
            PlayCardMechanics   = new PlayCardMechanics(this);
            StartTurnMechanics  = new StartTurnMechanics(this);
            FinishTurnMecahnics = new FinishTurnMecahnics(this);
            SpawnMechanics      = new SpawnMechanics(this);
            ManaMechanics       = new ManaMechanics(this);

            #endregion
        }
예제 #4
0
 void GetDynamicTarget(ITargetable target, PlayerSeat player)
 {
     if (player == TargetPlayer)
     {
         targets.Add(target);
     }
 }
예제 #5
0
        public override bool Populate(PlayerSeat Seat, int pos)
        {
            Outline outty = GetComponent <Outline>();

            actionOutline = new UiActionActive(this, outty);

            seat = Seat;

            contPlayer = GameData.Instance.RuntimeGame.Players.Find(player => player.Seat == seat);
            IRoster pRoster = contPlayer.Roster;

            if (pRoster.MoheRoster.Count <= pos)
            {
                return(false);
            }

            moheData = pRoster.MoheRoster[pos];

            headerTxt = transform.Find("HeaderTxt").GetComponent <TextMeshProUGUI>();
            lvlTxt    = transform.Find("LvlTxt").GetComponent <TextMeshProUGUI>();

            transform.Find("HealthBarImg").GetComponent <UiHealthBarFiller>().Populate(moheData);
            transform.Find("ExpBarImg").GetComponent <UiExpBarFiller>().Populate(moheData);
            moheImage = transform.Find("MohePortrait").GetComponent <Image>();

            headerTxt.text = moheData.BaseMohe.Data.Name;
            lvlTxt.text    = moheData.BaseExpType.CalculateLevel(moheData.Exp).ToString();

            moheImage.sprite = moheData.BaseMohe.Data.Artwork;

            OnToggle += OnSetSwap;

            return(true);
        }
예제 #6
0
        /*
         * Health
         * Progress w/ abilities
         */
        public RuntimeMoheData(IMohe Mohe, PlayerSeat seat, int idx)
        {
            baseMohe = Mohe;

            playerSeat  = seat;
            baseExpType = BaseExpType.TranslateType(baseMohe.Data.ExperienceType);
            instanceID  = baseMohe.Data.MoheID.ToString() + playerSeat + idx.ToString();
            Health      = (int)baseMohe.Stats.health;
            Exp         = 0;
            abilities   = new List <IRuntimeAbility>();
            List <AbilityData> db = AbilityDatabase.Instance.GetFullList();

            foreach (AbilityID abil in baseMohe.Abilities)
            {
                if (db?.Find(ability => ability.AbilityID == abil))
                {
                    abilities.Add(new RuntimeAbility(db?.Find(ability => ability.AbilityID == abil)));
                }
            }

            DamageMoheMechanic     = new DamageMoheMechanic(this);
            DeathMoheMechanics     = new DeathMoheMechanic(this);
            GainExpMoheMechanic    = new GainExpMoheMechanic(this);
            GainLvlMoheMechanic    = new GainLvlMoheMechanic(this);
            GainStatusMoheMehanic  = new GainStatusMoheMehanic(this);
            HealMoheMechanic       = new HealMoheMechanic(this);
            LoseStatusMoheMechanic = new LoseStatusMoheMechanic(this);
        }
예제 #7
0
        public IEnumerator ExecuteAiTurn(PlayerSeat seat)
        {
            // Clear board
            GameEvents.Instance.Notify <IRemoveSelectedBoard>(i => i.OnBoardRemoveSelectedCheck());

            // wait until the board state is clean.
            int count = 0;

            while (!BoardController.Instance.CanClickJewel() && count < 20)
            {
                yield return(new WaitForSeconds(1));

                Debug.Log("count: " + count.ToString());
                Debug.Log("state: " + BoardController.Instance.CurrentState.ToString());
                count++;
            }

            // Check to see if the computer can use any abilities
            IRuntimeMoheData mohe = GameController.Instance.GetPlayerController(seat).Player.Roster.CurrentMohe();

            yield return(new WaitForSeconds(.25f));

            if (mohe.UseableAbility())
            {
                Fsm.Handler.MonoBehaviour.StartCoroutine(ExecuteAiAbility(Seat));
            }
            else
            {
                Fsm.Handler.MonoBehaviour.StartCoroutine(ExecuteAiSwap(Seat));
            }

            yield return(null);
        }
예제 #8
0
        public IEnumerator ExecuteAiSwap(PlayerSeat seat)
        {
            List <SwapChoices> matchesBuff = AiModule.GetBestMove(seat);

            if (matchesBuff.Count > 0)
            {
                // click first gem
                GameEvents.Instance.Notify <ISelectJewel>(i => i.OnSelect(matchesBuff[0].jewel1));

                yield return(new WaitForSeconds(0.5f));

                while (!BoardController.Instance.CanManipulate())
                {
                }

                // click second gem
                GameEvents.Instance.Notify <ISelectJewel>(i => i.OnSelect(matchesBuff[0].jewel2));

                //while (!BoardController.Instance.CanManipulate()) { }

                AiFinishTurnRoutine = Fsm.Handler.MonoBehaviour.StartCoroutine(AiFinishTurn(AiFinishTurnDelay));
            }
            else
            {
                GameEvents.Instance.Notify <IResetBoard>(i => i.OnBoardResetCheck());
            }
        }
예제 #9
0
        public IEnumerator ExecuteAiAbility(PlayerSeat seat)
        {
            List <IRuntimeAbility> abilityBuff = AiModule.GetBestAbility(seat);

            if (abilityBuff.Count > 0)
            {
                GameObject GO = GameObject.FindGameObjectsWithTag("UiPanel").Where((go) => go.GetComponent <IUiPlayerHUD>().Seat == seat).ToList()[0];
                // Check for nav
                if (GO.GetComponent <IUiPlayerHUD>().UINavButtons.Current != NavID.Attack)
                {
                    // click on the ability
                    GameEvents.Instance.Notify <IPlayerNav>(i => i.OnPlayerNav(seat, NavID.Attack));
                    yield return(new WaitForSeconds(1f));
                }

                // click on the ability
                GameEvents.Instance.Notify <ISelectAtkActionButton>(i => i.OnSelectAtkActionButton(seat, abilityBuff[0].Ability.AbilityID));
                //Debug.Log("AI clicked on ability");

                yield return(new WaitForSeconds(1f));

                while (!BoardController.Instance.CanClickJewel())
                {
                }

                IRuntimeJewel jwl = AiModule.GetAbilityJewels(seat, abilityBuff[0])[0];
                GameEvents.Instance.Notify <ISelectJewel>(i => i.OnSelect(jwl));
                //Debug.Log("AI clicked on jewel");
                yield return(new WaitForSeconds(2f));
            }
            //while (!BoardController.Instance.CanManipulate()) { }
            //Debug.Log("AI ready to perform next action!");
            Fsm.Handler.MonoBehaviour.StartCoroutine(ExecuteAiTurn(seat));
        }
예제 #10
0
        // Listen to Ability charge update

        // Refresh UI on call

        public bool Populate(PlayerSeat Seat, IRuntimeAbility Ability, int ComponentIdx)
        {
            seat         = Seat;
            ability      = Ability;
            componentIdx = ComponentIdx;

            return(Refresh());
        }
예제 #11
0
 public Player(PlayerSeat seat, GameParameters gameParameters, Observer gameEvents)
 {
     GameParameters      = gameParameters;
     Seat                = seat;
     StartTurnMechanics  = new StartTurnMechanics(this);
     FinishTurnMechanics = new FinishTurnMechanics(this);
     GameEvents          = gameEvents;
 }
예제 #12
0
        private void EvaluateMoheDeath(PlayerSeat seat)
        {
            IRoster roster = GameController.Instance.GetPlayerController(seat).Player.Roster;

            if (roster.CurrentMohe().MoheDead())
            {
                GameEvents.Instance.Notify <IMoheDeath>(i => i.OnMoheDeath(roster.CurrentMohe().InstanceID));
            }
        }
예제 #13
0
        public override bool Execute(IRuntimeJewel TriggerJewel)
        {
            PlayerSeat       pSeat = EffectPlayer == PlayerEffectSeat.Active ? GameData.Instance.RuntimeGame.TurnLogic.CurrentPlayer.Seat : GameData.Instance.RuntimeGame.TurnLogic.NextPlayer.Seat;
            IRuntimeMoheData mohe  = GameController.Instance.GetPlayerController(pSeat).Player.Roster.CurrentMohe();

            GameEvents.Instance.Notify <IMoheHeal>(i => i.OnMoheHeal(mohe.InstanceID, (int)Random.Range(MinAmt, MaxAmt)));

            return(true);
        }
예제 #14
0
 public void OnPlayerNav(PlayerSeat Seat, NavID Nav)
 {
     if (Seat == seat)
     {
         Debug.Log("OnPlayerNav: " + Seat);
         current = Nav;
         OnNavigate?.Invoke(Current);
     }
 }
예제 #15
0
        public IUiAttackCost Get(PlayerSeat seat, IRuntimeAbility ability, int componentIdx)
        {
            var obj = Get <IUiAttackCost>();

            if (!obj.Populate(seat, ability, componentIdx))
            {
                return(null);
            }
            return(obj);
        }
예제 #16
0
 // Start is called before the first frame update
 void Start()
 {
     //gameManager = GameObject.Find("GameManager");
     spawner         = GameObject.Find("Spawner").GetComponent <KidSpawnerManager>();
     gameManager     = GameObject.Find("GameManager").GetComponent <GameManager>();
     player          = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerSeat>();
     targetManager   = GameObject.FindGameObjectWithTag("TargetManager");
     GOChildPoubelle = GameObject.Find("GOChildPoubelle");
     animator        = GetComponentInChildren <Animator>();
 }
예제 #17
0
        public IRoster CreateTestRoster(PlayerSeat seat)
        {
            List <IRuntimeMoheData> moheList = new List <IRuntimeMoheData>()
            {
                CreateTestMohe(MoheID.Beanlock, seat),
                CreateTestMohe(MoheID.SunSlime, seat)
            };

            return(new Roster(moheList));
        }
예제 #18
0
파일: AIModule.cs 프로젝트: BradZzz/Moheum
        //----------------------------------------------------------------------------------------------------------

        #region Operations

        /// <summary>
        ///     Returns the best move according to the current ai submodule.
        /// </summary>
        /// <returns></returns>
        public List <SwapChoices> GetBestMove(PlayerSeat seat)
        {
            if (!subModules.ContainsKey(CurrentAi))
            {
                throw new ArgumentOutOfRangeException(
                          CurrentAi + " is not registered as a valid archetype in this module.");
            }

            return(subModules[CurrentAi].GetSwapMoves(seat));
        }
예제 #19
0
파일: AIModule.cs 프로젝트: BradZzz/Moheum
        /// <summary>
        ///     Returns the best ability according to the current ai submodule.
        /// </summary>
        /// <returns></returns>
        public List <IRuntimeJewel> GetAbilityJewels(PlayerSeat seat, IRuntimeAbility ability)
        {
            if (!subModules.ContainsKey(CurrentAi))
            {
                throw new ArgumentOutOfRangeException(
                          CurrentAi + " is not registered as a valid archetype in this module.");
            }

            return(subModules[CurrentAi].GetAbilityJewel(seat, ability));
        }
예제 #20
0
        public IUiActionButton Get(PlayerSeat seat, int idx)
        {
            var obj = Get <IUiActionButton>();

            if (!obj.Populate(seat, idx))
            {
                return(null);
            }
            return(obj);
        }
예제 #21
0
 public IPlayer GetPlayer(PlayerSeat seat)
 {
     foreach (var player in Players)
     {
         if (player.Seat == seat)
         {
             return(player);
         }
     }
     return(null);
 }
예제 #22
0
    private void OnTriggerEnter(Collider collider)
    {
        if (collider.tag == "Player")
        {
            PlayerSeat seat = collider.GetComponent <PlayerSeat>();

            seat.client.GetComponent <Kid2>().Disembark();
            seat.seatAvailable = true;
            Debug.Log("Seat available");
        }
    }
예제 #23
0
 /// <summary>
 ///     Returns a the player turn according to the position. Null if there isn't player registered with the argument.
 /// </summary>
 /// <param name="seat"></param>
 /// <returns></returns>
 public TurnState GetPlayerController(PlayerSeat seat)
 {
     foreach (var player in actorsRegister.Keys)
     {
         if (player.Seat == seat)
         {
             return(actorsRegister[player]);
         }
     }
     return(null);
 }
예제 #24
0
        public IRuntimeMoheData CreateTestMohe(MoheID moheID, PlayerSeat seat)
        {
            MoheData mData = MoheDatabase.Instance.Get(moheID);

            MoheData.MoheStatData stats = new MoheData.MoheStatData();
            stats.health = 10;
            Mohe            sampleMohe        = new Mohe(mData, mData.Abilities.Select(ability => ability.ability.AbilityID).ToList(), stats);
            RuntimeMoheData sampleRuntimeMohe = new RuntimeMoheData(sampleMohe, seat, 1);

            return(sampleRuntimeMohe);
        }
예제 #25
0
 public IPlayerTurn GetOpponentPlayersController(PlayerSeat Seat)
 {
     if (Seat == PlayerSeat.Left)
     {
         return(TurnBasedLogic.GetPlayerController(PlayerSeat.Right));
     }
     else
     {
         return(TurnBasedLogic.GetPlayerController(PlayerSeat.Left));
     }
 }
예제 #26
0
 public void OnSelectAtkActionButton(PlayerSeat Seat, AbilityID Id)
 {
     if (Seat == seat && ability != null && Id == ability.Ability.AbilityID)
     {
         OnToggle.Invoke(!actionOutline.Active);
         GameEvents.Instance.Notify <IActionBoard>(i => i.OnBoardActionCheck(seat, actionOutline.Active ? ability : null));
     }
     else
     {
         OnToggle.Invoke(false);
     }
 }
예제 #27
0
파일: Player.cs 프로젝트: BradZzz/Moheum
        public Player(PlayerSeat seat, IRoster Roster, Battle.Configurations.Configurations configurations = null)
        {
            Configurations = configurations;
            Seat           = seat;
            roster         = Roster;

            StartTurnMechanics     = new StartTurnMechanics(this);
            FinishTurnMechanics    = new FinishTurnMechanics(this);
            SwapTurnMechanics      = new SwapTurnMechanics(this);
            SwapMoheMechanics      = new SwapMoheMechanics(this);
            ChargeAbilityMechanics = new ChargeAbilityMechanics(this);
            //UseAbilityMechanics = new UseAbilityMechanics(this);
            GainJewelBonusMechanics = new GainJewelBonusMechanics(this);
        }
예제 #28
0
 public void OnBoardActionCheck(PlayerSeat seat, IRuntimeAbility ability)
 {
     board.OnInvokeActionEffect = null;
     board.OnCleanAbility       = null;
     if (ability != null && ability.Ability.AfterEffect != null)
     {
         board.OnInvokeActionEffect += ability.Ability.AfterEffect.Execute;
         board.OnCleanAbility       += ability.ResetAbility;
         NotifyAction();
     }
     else
     {
         NotifyEvaluate();
     }
 }
예제 #29
0
파일: GameCell.cs 프로젝트: tgrosh/hX
    private void SetOwner(Player player)
    {
        prevOwner = owner;
        prevSeat  = ownerSeat;

        if (player == null)
        {
            owner     = NetworkInstanceId.Invalid;
            ownerSeat = PlayerSeat.Empty;
        }
        else
        {
            owner     = player.netId;
            ownerSeat = player.seat;
        }
    }
예제 #30
0
    public void OnPlayerNav(PlayerSeat seat, NavID nav)
    {
        if (seat != parent.Seat)
        {
            return;
        }

        if (nav == parent.NavID)
        {
            outline.enabled = true;
        }
        else
        {
            outline.enabled = false;
        }
    }
예제 #31
0
        /// <summary>
        /// Returns statistics of a player having an asked card (0 means - no chance)
        /// </summary>
        /// <param name="player">asked player</param>
        /// <param name="card">asked card</param>
        /// <returns></returns>
        protected double getCardStatistic(PlayerSeat player, Card card)
        {
            //check if player have suit?
            if (!getPlayerSuitStatus(player, card.Suit))
            {
                return 0;
            }

            //check if card was thrown before?
            if (m_playedCards[(int)card.Suit - 1].Contains(card.Value))
            {
                return 0;
            }

            //check if card was played in this play?
            for (int i = (int)CurrentRoundStatus.LeadingPlayer; i < 4; i++)
            {
                Card? tmp = CurrentRoundStatus.CurrentPlay[i % 4];
                if (tmp != null)
                {
                    m_playedCards[(int)tmp.Value.Suit - 1].Add(tmp.Value.Value);

                    if (CurrentRoundStatus.CurrentPlay[i % 4].Equals(card))
                    {
                        return 0;
                    }
                }
                else
                {
                    break;
                }
            }

            //card was not thrown yet. calculate statistics (acctually left!=0 otherwise we already returned... but who cares...)
            int left = (13 - m_playedCards[(int)card.Suit - 1].Count);
            double retVal = (left == 0) ? 0 : 1/left;

            return retVal;
        }
예제 #32
0
 public Card? GetCurrentPlay(PlayerSeat seat)
 {
     return CurrentPlay[(int)seat];
 }
예제 #33
0
 public void RecieveChatMessage(PlayerSeat sender, string msg)
 {
     // nothing to do
 }
예제 #34
0
 public void RecieveChatMessage(PlayerSeat sender, string msg)
 {
     try
     {
         this.webClient.RecieveChatMessage(sender, msg);
     }
     catch { }
 }
예제 #35
0
 /// <summary>
 /// return true if player p got more cards of asked suit
 /// return false if player p have no more cards of asked suit
 /// </summary>
 /// <param name="p">asked player</param>
 /// <param name="s">asked suit</param>
 /// <returns></returns>
 protected bool getPlayerSuitStatus(PlayerSeat p, Suit s)
 {
     return !m_playerEmptySuits[(int)p - 1].Contains(s);
 }
예제 #36
0
 public Bid? GetBid(PlayerSeat seat)
 {
     return Biddings[(int)seat];
 }
예제 #37
0
 public int GetTricks(PlayerSeat seat)
 {
     return TricksTaken[(int)seat];
 }
예제 #38
0
 private void WriteToChat(PlayerSeat playerSeat, string _msg)
 {
     string msg = "";
     msg += currentGameStatus.PlayerNamesk__BackingField[(int)playerSeat];
     msg += ": " + _msg;
     txt_chat.Text += msg + "\n";
     scrl_chat.ScrollToVerticalOffset(4000.0);
 }