Exemplo n.º 1
0
 public void PlayerCanHaveCashSet()
 {
     Player p = new Player();
     int startingCash = p.Cash;
     p.SetCash(startingCash + 100);
     Assert.IsTrue(p.Cash == (startingCash + 100));
 }
Exemplo n.º 2
0
        public static void CheckAuction(Game g, Player bot)
        {
            var p = bot;

            var cell = g.currAuction.cell;

            var sum = g.GetPlayerCash(p.Id);

            var fact = BotBrain.FactorOfBuy(g, p, cell);

            var aucSum = cell.Cost * fact;

            if (sum >= aucSum && aucSum > g.currAuction.nextBid)
            {
                g.currAuction.currBid = g.currAuction.nextBid;
                g.Tlog("Auction.Yes", "@p{0} дает {1}", "@p{0} bid {1}", p.Id, g.currAuction.currBid.PrintMoney());
                g.currAuction.LastBiddedPlayer = p;

            }
            else
            {
                g.Tlog("Auction.No", "@p{0} выбывает", "@p{0} is out", p.Id);
                //g.aucState.allPlayers = g.aucState.allPlayers.Where(x => x.Id != p.Id).ToList();
                p.InAuction = false;
            }
        }
Exemplo n.º 3
0
        public ActionResult AddBot(Guid id)
        {
            if (Request.IsAuthenticated)
            {
                var uname1 = User.Identity.Name;

                var g = FindGameByID(id);
                if (g != null)
                {
                    //Session["gid"] = id.ToString();

                    var plCount = g.Players.Count;
                    if (plCount < g.conf.cnfMaxPlayers && g.Players[0].Name == uname1)
                    {
                        var uname = "comp" + plCount;
                        var pl = new Player { Id = plCount, Name = uname, IsBot = true, Status = GetStatus(uname), Money = Const.START_CASH };
                        g.Players.Add(pl);
                        if (g.Players.Count == g.conf.cnfMaxPlayers)
                        {
                            g.StartGame();
                            return RedirectToAction("Play", "Game");
                        }

                    }
                    return RedirectToAction("Index");

                }
            }
            else
            {
                RedirectToAction("LogOn", "Account");
            }

            return RedirectToAction("Index");
        }
Exemplo n.º 4
0
 public void PlayerCanHaveCashAdded()
 {
     Player p = new Player();
     int startingCash = p.Cash;
     p.AddCash(10);
     Assert.IsTrue(p.Cash == (startingCash + 10));
 }
        public Game(string name)
        {
            shaman = new Player(name, 0);         //vanno inizializzati
            opponent = new Player("Opponent", 1); //vanno inizializzati
            comm = Communication.Communicator.getInstance();


        }
Exemplo n.º 6
0
 public StackButton(Texture2D texture, Player p, SpriteBatch sBatch, Thing t, Tile hex, int width, int height, int x, int y)
     : base(texture, sBatch, width, height, x, y)
 {
     image = texture;
     thingsInStack = new List<Thing>(10);
     thingsInStack.Add(t);
     hexStackIsOn = hex;
     owner = p;
 }
Exemplo n.º 7
0
 public void PlayerAddedToArenaDefaultLocationIsBottomLeftCentreOfArenaForEvenWidth()
 {
     var p = new Player();
     var a = new Arena();
     a.BuildArenaFloor(8);
     a.AddPlayerToArena(p);
     a.SetDefaultPlayerLocation();
     Assert.IsTrue(p.CharacterLocation.XCoord == a.ArenaFloor.GetLength(0) - 1 && p.CharacterLocation.YCoord == 3);
 }
Exemplo n.º 8
0
        void Start()
        {
	    	instance = this; 
            InitializeInternals();
            Screen.lockCursor = true;
            Cursor.visible = false;

			left = true;
			right = false;
        }
Exemplo n.º 9
0
 public void PlayerCanAffordAffordableEquipment()
 {
     Player p = new Player();
     Sword s = new Sword();
     if (p.Cash < s.Price)
     {
         p.AddCash(s.Price);
     }
     Assert.IsTrue(p.CanAffordEquipment(s));
 }
Exemplo n.º 10
0
 public void PlayerCannotAffordUnaffordableEquipment()
 {
     Player p = new Player();
     Sword s = new Sword();
     if (p.Cash >= s.Price)
     {
         p.SetCash(s.Price-100);
     }
     Assert.IsFalse(p.CanAffordEquipment(s));
 }
Exemplo n.º 11
0
 public ActionResult CreateCharacter(UICharacterModel model)
 {
     if (!ModelState.IsValid)
     {
         return View("Index", model);
     }
     var p = new Player();
     p.SetName(model.Name);
     Session["Player"] = p;
     return View("Character", p);
 }
Exemplo n.º 12
0
 public TournamentInstance(TournamentInfo tournamentInfo, GameLogic.Player player)
 {
     this.OutgoingLogQueue            = new List <TournamentLogEvent>();
     this.HeroStats                   = new GameLogic.HeroStats();
     this.Resources                   = new Dictionary <string, double>();
     this.Upgrades                    = new TournamentUpgrades();
     this.LastAdventurePanelSubTabIdx = -1;
     this.TournamentId                = tournamentInfo.Id;
     this.Player       = player;
     this.CurrentState = State.PENDING_JOIN_CONFIRMATION;
 }
Exemplo n.º 13
0
 public ThingButton(Texture2D texture, Player p, SpriteBatch sBatch, Thing t, int width, int height, int x, int y)
     : base(texture, sBatch, width, height, x, y)
 {
     owner = p;
     buttonID = t.getID();
     thingOnButton = t;
     thingOnButton.setOwned();
     owner.AddThingToRack(buttonID, t);
     thingSelected = false;
     isInPlay = false;
     originalPosition = location;
 }
Exemplo n.º 14
0
        public BuildingButton(Texture2D texture, Player p, SpriteBatch sBatch, int width, int height, int x, int y)
            : base(texture, sBatch, width, height, x, y)
        {
            buildingSelected = false;
            isSet = false;
            owner = p;

            Random r = new Random();

            buttonID = r.Next(System.DateTime.Now.Millisecond * 1000, System.DateTime.Now.Millisecond * 10000);
            System.Threading.Thread.Sleep(1000);

            while (p.containsMarkerID(buttonID))
            {
                buttonID = r.Next(System.DateTime.Now.Millisecond);
                System.Threading.Thread.Sleep(1000);
            }

            owner.addMarkerID(buttonID);
        }
Exemplo n.º 15
0
        public static int GetCashForHouses(Game g, Player p)
        {
            var cells = g.Map.CellsByUser(p.Id).Where(a => !a.IsMortgage);

            var lands = cells.Where(x => !x.IsMonopoly && x.Type == 1);

            var landsMon000 = cells.Where(x => x.IsMonopoly).GroupBy(x => x.Group).
                Where(x => x.All(a => a.HousesCount == 0)).SelectMany(x => x);

            var transPower = cells.Where(x => x.Type == 2 || x.Type == 3);

            var sum = 0;

            foreach (var cell in lands.Union(transPower).Union(landsMon000))
            {
                sum += cell.MortgageAmount;
                cell.IsMortgage = true;
            }

            return sum;
        }
Exemplo n.º 16
0
 public override bool canAttackPlayer(Player targetPlayer) //controllo se posso attaccare l'opponent oppure possiede una creatura con protezione ecc ecc...
 {
     if (this.hasAttacked == false && !this.debuff.Contains(Enums.Debuff.Asleep)) // check se ha già attaccato o se è addormentato
     {
         if (this.properties.Contains(Enums.Properties.Quickness) || this.hasWeakness == false) //check se ha debolezza da invocazione o Quickness
         {
             if (targetPlayer.cardsOnBoard != null)
             {
                 foreach (Elemental elemTemp in targetPlayer.cardsOnBoard)
                 {
                     if (elemTemp.properties.Contains(Enums.Properties.Guardian)) // check se l'opponent ha elementali con Guardian
                         return false;
                 }
                 return true;
             }
         }
     }
     return false;        
 }
Exemplo n.º 17
0
        public override Player attackPlayer(Player targetPlayer) //Attacco l'opponent e ritorno le eventuali modifiche.
        {
            for (int dmg = 0; dmg < this.strength; dmg++)
                targetPlayer.hp -= 1;

            if (this.properties.Contains(Enums.Properties.Thunderborn) && this.hasAttackedThunderborn == false)
                this.hasAttackedThunderborn = true;
            else
                this.hasAttacked = true;

            return targetPlayer;
        }
Exemplo n.º 18
0
 public void PlayerCannotBeAddedToArenaWhenFloorNotBuilt()
 {
     var p = new Player();
     var a = new Arena();
     a.AddPlayerToArena(p);
 }
Exemplo n.º 19
0
 public void PlayerCanBeAddedToArena()
 {
     var p = new Player();
     var a = new Arena();
     a.BuildArenaFloor(5);
     a.AddPlayerToArena(p);
     Assert.IsTrue(a.Player == p);
 }
Exemplo n.º 20
0
        public static void UnMortgageLands(Game g, Player p)
        {
            //if (!BotBrain.NeedBuildHouses(g)) return;

            var trans = g.Map.CellsByUserByGroup(p.Id, 11);

            string text = "";

            if (trans.Count() > 2)
                text += UnMortg(g, trans);

            var cellsMon = g.Map.CellsByUser(p.Id).Where(x => x.IsMortgage && x.IsMonopoly)
                .GroupBy(x => x.Group);

            if (cellsMon.Any())
            {
                //Mortgage(g, p, cellsMon.First().UnMortgageAmount);
                text += UnMortg(g, cellsMon.FirstOrDefault());
            }

            //var cells = g.Map.CellsByUser(p.Id).Where(x => x.IsMortgage);
            //UnMortg(g, cells);

            if (text != "")
            {
                g.FixAction("unmortgage" + text);
            }
        }
Exemplo n.º 21
0
 public void PlayerDefaultLocationCannotBeSetIfArenaFloorNull()
 {
     var p = new Player();
     var a = new Arena();
     a.AddPlayerToArena(p);
     a.SetDefaultPlayerLocation();
 }
Exemplo n.º 22
0
 public void SetOwner(Player p, CellInf cell)
 {
     cell.Owner = p.Id;
     cell.IsMortgage = false;
     p.Money -= cell.Cost;
     UpdateMap();
 }
Exemplo n.º 23
0
        public static Game RestoreGameFromXML(string xml)
        {
            var xdoc = XDocument.Parse(xml);

            var g = new Game();

            g.Id = Guid.Parse(xdoc.Root.Attribute("gid").Value);

            g.Selected = Int32.Parse(xdoc.Root.Attribute("CurrId").Value);
            g.RunningGame = true;
            g.conf.cnfRollMode = Int32.Parse(xdoc.Root.Attribute("RollMode").Value);
            g.conf.cnfTimeOut = Int32.Parse(xdoc.Root.Attribute("TimeOut").Value);
            g.RoundNumber = Int32.Parse(xdoc.Root.Attribute("Round").Value);

            var pNames = xdoc.Root.Attribute("Players").Value.Split(';');
            int ids = 0;
            foreach (var pl in xdoc.Descendants("Player"))
            {
                var p = new Player();

                p.Id = Int32.Parse(pl.Attribute("PlayerId").Value);
                p.Name = pNames[p.Id];
                p.Money = Int32.Parse(pl.Attribute("money").Value);
                p.Pos = Int32.Parse(pl.Attribute("pos").Value);
                p.IsBot = pl.Attribute("isBot").Value == "true";
                p.Status = "beginner";

                var plSteps = pl.Attribute("lastRolls") == null ? "" : pl.Attribute("lastRolls").Value;
                p.PlayerSteps = string.IsNullOrWhiteSpace(plSteps) ? new List<int>() : plSteps.Split(':').Select(x => Int32.Parse(x)).ToList();

                if (p.PlayerSteps.Count() > 2)
                    p.LastRoll = new[] { p.PlayerSteps[2] / 10, p.PlayerSteps[2] % 10 };

                g.Players.Add(p);

                InitLandsWhenRestoreGame(g, p, pl);

                ids++;
            }

            return g;
        }
Exemplo n.º 24
0
 private void AddPlayer(string i_Name, Player.ePlayerType i_PlayerType, Coin.eCoinType i_CoinType)
 {
     this.m_Players.Add(new Player(i_Name, i_PlayerType, i_CoinType));
 }
Exemplo n.º 25
0
        public static bool Mortgage(Game g, Player p, int PayAmount, bool InclMon = false)
        {
            if (p.Money >= PayAmount) return true;

            var cells = g.Map.CellsByUser(p.Id).Where(a => !a.IsMortgage);

            //select non monopoly cells-type1
            var lands = cells.Where(x => !x.IsMonopoly && x.Type == 1);

            //select trans and power cells
            var transPower = cells.Where(x => x.Type == 2 || x.Type == 3);

            //select monopoly without houses
            IEnumerable<CellInf> q = lands.Union(transPower);

            if (InclMon)
            {
                var landsMon000 = cells.Where(x => x.IsMonopoly).GroupBy(x => x.Group).
                Where(x => x.All(a => a.HousesCount == 0)).SelectMany(x => x);
                q = q.Union(landsMon000);
            }

            string text = "";

            foreach (var cell in q)
            {
                if (p.Money >= PayAmount) break;

                p.Money += cell.MortgageAmount;
                cell.IsMortgage = true;
                text = text + "_" + cell.Id;
            }

            if (!string.IsNullOrEmpty(text))
            {
                g.FixAction("mortgage" + text);
            }

            return (p.Money >= PayAmount);
        }
Exemplo n.º 26
0
        public static bool MortgageSell(Game g, Player p, int PayAmount)
        {
            //p.Money -= PayAmount;
            if (p.Money >= PayAmount) return true;

            //1 - mortage non monopoly lands
            BotBrain.Mortgage(g, p, PayAmount);

            //2 - sell houses
            BotBrainHouses.SellHouses(g, PayAmount);

            //3 -mortage monopoly without houses
            BotBrain.Mortgage(g, p, PayAmount, true);

            return p.Money >= PayAmount;
        }
Exemplo n.º 27
0
        public void postDeserializeInitialization()
        {
            this.Upgrades.Player = this.Player;
            this.Upgrades.postDeserializeInitialization();
            IEnumerator enumerator = Enum.GetValues(typeof(ResourceType)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ResourceType current = (ResourceType)((int)enumerator.Current);
                    if (!this.Resources.ContainsKey(current.ToString()))
                    {
                        this.Resources.Add(current.ToString(), 0.0);
                    }
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable == null)
                {
                }
                disposable.Dispose();
            }
            if ((this.Inventory == null) || (this.ItemSlots == null))
            {
                GameLogic.Player player = JsonUtils.Deserialize <GameLogic.Player>(ResourceUtil.LoadSafe <TextAsset>("Players/humanPlayer1", false).text, true);
                if (this.ItemSlots == null)
                {
                    this.ItemSlots = player.ActiveCharacter.ItemSlots;
                }
                if (this.Inventory == null)
                {
                    this.Inventory = player.ActiveCharacter.Inventory;
                }
            }
            IEnumerator enumerator2 = Enum.GetValues(typeof(ItemType)).GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    ItemType type2 = (ItemType)((int)enumerator2.Current);
                    if (type2 != ItemType.UNSPECIFIED)
                    {
                        bool flag = false;
                        for (int n = 0; n < this.ItemSlots.Count; n++)
                        {
                            if (this.ItemSlots[n].CompatibleItemType == type2)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            ItemSlot item = new ItemSlot();
                            item.CompatibleItemType = type2;
                            this.ItemSlots.Add(item);
                        }
                    }
                }
            }
            finally
            {
                IDisposable disposable2 = enumerator2 as IDisposable;
                if (disposable2 == null)
                {
                }
                disposable2.Dispose();
            }
            this.Inventory.postDeserializeInitialization();
            for (int i = 0; i < this.ItemSlots.Count; i++)
            {
                this.ItemSlots[i].postDeserializeInitialization();
            }
            for (int j = 0; j < this.ItemSlots.Count; j++)
            {
                if (this.ItemSlots[j].ItemInstance != null)
                {
                    this.ItemSlots[j].ItemInstance.enforcePerkLegality(this.Player);
                }
            }
            for (int k = 0; k < this.Inventory.ItemInstances.Count; k++)
            {
                this.Inventory.ItemInstances[k].enforcePerkLegality(this.Player);
            }
            for (int m = 0; m < this.ItemSlots.Count; m++)
            {
                ItemInstance itemInstance = this.ItemSlots[m].ItemInstance;
                if (itemInstance != null)
                {
                    itemInstance.InspectedByPlayer = true;
                }
            }
            this.WildBossSpawnChance = ConfigTournaments.TOURNAMENT_WILD_BOSS_SPAWN_CHANCE_BASE;
        }
Exemplo n.º 28
0
        public static bool NeedBuy(Game g, Player p, CellInf cell)
        {
            var fact = BotBrain.FactorOfBuy(g, p, cell);

            bool needBuy = false;

            if (fact >= 100)
                needBuy = BotBrain.MortgageSell(g, p, cell.Cost);

            else if (fact >= 1)
                needBuy = BotBrain.Mortgage(g, p, cell.Cost);

            return needBuy;
        }
Exemplo n.º 29
0
 public bool canUsePower(Player param)
 {
     return true;
 }
Exemplo n.º 30
0
 private static void InitLandsWhenRestoreGame(Game g, Player p, XElement pl)
 {
     foreach (var cell in pl.Descendants("Cell"))
     {
         var cc = g.Cells[Int32.Parse(cell.Attribute("cid").Value)];
         cc.Owner = p.Id;
         //house count
         var value = cell.Value.Split(',');
         cc.HousesCount = Int32.Parse(value[0]);
         cc.IsMortgage = Int32.Parse(value[1]) == 1;
     }
     g.Map.UpdateMap();
 }
Exemplo n.º 31
0
 public override bool canAttackElem(Elemental targetElem, Player controller)
 {
     if (this.hasAttacked == false && !this.debuff.Contains(Enums.Debuff.Asleep)) // check se ha già attaccato o se è addormentato
     {
         if (this.properties.Contains(Enums.Properties.Quickness) || this.hasWeakness == false) //check se ha debolezza da evocazione o Quickness
         {
             if (!targetElem.properties.Contains(Enums.Properties.Guardian)) // se il target non ha Guardian, check su tutti gli elementali dell'opponent, per vedere se hanno Guardian.
                 foreach (Elemental elemTemp in controller.cardsOnBoard)
                 {
                     if (elemTemp.properties.Contains(Enums.Properties.Guardian))
                         return false;
                 }
             return true;
         }
     }
     return false;
 }
Exemplo n.º 32
0
        public static double FactorOfBuy(Game g, Player p, CellInf cell)
        {
            double isNeedBuy = 0;
            if (GameHelper.GetPlayerAssets(g, p.Id) < cell.Cost) return 0;

            var groupsWithHouses = BotBrainHouses.GetGroupsWhereNeedBuildHouses(g, p);
            var needBuild = groupsWithHouses.Any();

            //--buy
            var gg = g.Map.CellsByGroup(cell.Group);

            //other monopoly
            var notMine = gg.Where(x => x.Owner.HasValue && x.Owner != p.Id);

            var myCount = gg.Count(x => x.Owner == p.Id);

            int aCount = 0;
            int? owPid = null;

            if (notMine.Any())
            {
                aCount = notMine.Max(x => x.OwGrCount);
                owPid = notMine.First(x => x.OwGrCount == aCount).Owner;
            }

            var manualFactor = GetManualFactor(g.AucRules, cell.Group, myCount, aCount, groupsWithHouses);
            if (manualFactor.HasValue) return manualFactor.Value;

            var cg = cell.Group;

            //if another monopoly
            if (aCount == 2 && owPid.HasValue)
            {
                var sum = g.GetPlayerCash(owPid.Value);
                if (cg == 2 && sum > 4000000) return 100;
                if (cg == 3 && sum > 4000000) return 100;
                if (cg == 4 && sum > 5000000) return 100;
                if (cg == 5 && sum > 7000000) return 100;

                if (cell.Type == 1) return 1.7;
            }

            if (needBuild) return 0;

            if (cg == 1 || cg == 8)
                isNeedBuy = Factor_1_8(cg, aCount);

            if (cg == 11 && !needBuild)
            {
                if (aCount > 2) isNeedBuy = 2;
                else
                    isNeedBuy = 1.5;

            }
            if (cg == 33)
                isNeedBuy = Factor_11_33(cg, aCount);

            //my second cell
            if (myCount == 1) isNeedBuy = 2.2;

            //my monopoly
            if (myCount == 2) isNeedBuy = 3;

            if (aCount == 1 && cell.Group != 1 && cell.Group != 8) isNeedBuy = 2;

            //first land
            if (gg.Count(x => x.Owner == null) == 3 && !needBuild)
                isNeedBuy = 1.4;

            return isNeedBuy;
        }