示例#1
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            // data submitted; log it and continue to wait
            if (form["data"] != null)
            {
                playerTask.data = playerTask.data.Split(',')[0] + "," + form["data"];
                playerTask.Save();
                return;
            }

            // all submissions have been made
            string status = GetStatus(playerTask);

            if (status == "")
            {
                return;
            }

            // personal bonus for getting it right
            if (Convert.ToInt32(playerTask.data.Split(',')[1]) == GetProduct())
            {
                player.Rank += 10;
            }
            else
            {
                player.Rank -= 10;
                Notification.CreatePlayer(string.Join(" x ", GetSummitTasks().Select(o => o.data.Split(',')[0])) + " = " + GetProduct() + ". Duh.", player.id);
            }
            player.Save();

            if (IsPrimary(playerTask))
            {
                if (status == "True")
                {
                    foreach (var pt in GetSummitTasks())
                    {
                        pt.GetPlayer.GetTeam.score += 15;
                        pt.GetPlayer.GetTeam.Save();
                    }
                    Newsfeed.Create("The Earth Plutocratic Congress Interagency Technology Summit is once again an overwhelming success.", Newsfeed.Context.success);
                }
                else
                {
                    foreach (var pt in GetSummitTasks())
                    {
                        pt.GetPlayer.GetTeam.score -= 8;
                        pt.GetPlayer.GetTeam.Save();
                    }

                    Newsfeed.Create("Tragedy at the Earth Plutocratic Congress Interagency Technology Summit caused by a simple mathematical error.", Newsfeed.Context.warning);
                }
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#2
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player         = Player.Load(playerTask.playerId);
            int    opponentTaskId = Convert.ToInt32(playerTask.data.Split(',')[0]);

            // player has made their choice
            if (form["choice"] != null)
            {
                playerTask.data = opponentTaskId + "," + form["choice"];
                playerTask.Save();
                return;
            }

            // both players have made their choices
            PlayerTask opponentTask = PlayerTask.Load(opponentTaskId);

            string myChoice       = playerTask.data.Split(',')[1];
            string opponentChoice = opponentTask.data.Split(',')[1];

            if (myChoice == "coop" && opponentChoice == "coop")
            {
                Notification.CreatePlayer("Both you and <b>" + opponentTask.GetPlayer.Name + "</b> cooperated with one another and have received your just rewards.", player.id);
                player.Rank += 12;
                player.Save();

                player.GetTeam.score += 13;
                player.GetTeam.Save();

                player.GiveRandomItem(Math.Min(player.AvailableItemSlots, 2));
            }
            else if (myChoice == "betray" && opponentChoice == "coop")
            {
                Notification.CreatePlayer("You betrayed <b>" + opponentTask.GetPlayer.Name + "</b> while they tried to cooperate with you.", player.id);
                player.GiveRandomItem(Math.Min(player.AvailableItemSlots, 1));
            }
            else if (myChoice == "coop" && opponentChoice == "betray")
            {
                Notification.CreatePlayer("You were betrayed by <b>" + opponentTask.GetPlayer.Name + "</b>.", player.id);
                player.Rank -= 10;
                player.Save();
            }
            else                 // betray/betray
            {
                Notification.CreatePlayer("You both betrayed one another.", player.id);
                player.Rank += 10;
                player.Save();
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#3
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            // player has started their device
            if (form["start"] != null)
            {
                playerTask.data = form["start"] + "," + DateTime.Now.Ticks;
                playerTask.Save();
                return;
            }

            // timing failed!
            if (GetStatus(playerTask).StartsWith("Fail"))
            {
                // only do these things once
                if (IsPrimaryTask(playerTask))
                {
                    Notification.CreateTeam("An explosion rocks the primary laboratory! Your team's lead researchers have failed to properly assembly the final construction. Minor damage results.", player.teamId);
                    player.GetTeam.score -= 20;                     // drop a tech level, but the items are not destroyed
                    player.GetTeam.Save();
                }

                playerTask.State = Task.TaskState.Completed;
                playerTask.Save();
                return;
            }

            // success
            if (GetStatus(playerTask).StartsWith("Done"))
            {
                // only do these things once
                if (IsPrimaryTask(playerTask))
                {
                    Notification.CreateTeam("A stillness descends over the primary laboratory. Your team's lead researchers have assembled the final form of the strange alien technology and made it available to all agents.", player.teamId);
                    // delete everyone's items and give them all the final form
                    foreach (Player p in player.GetTeam.GetPlayers)
                    {
                        foreach (PlayerItem item in p.GetItems)
                        {
                            item.Delete();
                        }
                        p.AddItem("timemachine");
                    }
                }

                playerTask.State = Task.TaskState.Completed;
                playerTask.Save();
                return;
            }
        }
示例#4
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            if (form["decision"] == "switch")
            {
                player.Team           = Team.Load(playerTask.data);
                player.MustReload     = true;
                player.GetTeam.score += 10;
                Notification n = Notification.CreateTeam("<b>" + player.Name + "</b> has switched teams and joined <b>" + player.GetTeam.name + "</b>.", player.GetTeam.id);
                player.ReadNotifications.Add(n.id);
                foreach (PlayerTask task in player.GetTasks)
                {
                    task.Delete();                                                          // delete all your waiting tasks
                }
                Notification.CreatePlayer("Welcome to <b>" + player.GetTeam.name + "</b>.", player.id);
            }
            else                 // stayed with current team
            {
                player.Rank += 8;
                Notification.CreatePlayer("<b>" + player.GetTeam.name + "</b> appreciates your continued and compulsory loyalty.", player.id);
            }

            player.Save();
        }
示例#5
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            player.AddItem(playerTask.data);
        }
示例#6
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            if (form["money"] != null)
            {
                playerTask.data = form["money"];
                playerTask.Save();
                return;
            }

            // if they haven't any slots, then give the team a tech bonus instead
            if (player.AvailableItemSlots == 0)
            {
                player.GetTeam.score += Convert.ToInt32(form["win"]) * 10;
                player.GetTeam.Save();
                Notification.CreatePlayer("Through shrewd negotiation you manage to convince the space casino to convert your winnings into a research grant for your team.", player.id);
            }

            if (form["win"] == "3")
            {
                player.GiveRandomItem(Math.Min(3, player.AvailableItemSlots));
                player.Rank += 15;
            }
            else if (form["win"] == "2")
            {
                player.GiveRandomItem(Math.Min(2, player.AvailableItemSlots));
                player.Rank += 9;
            }
            else if (form["win"] == "1")
            {
                player.GiveRandomItem(Math.Min(1, player.AvailableItemSlots));
                player.Rank += 4;
            }
            else if (form["win"] == "0")
            {
                player.Rank -= 9;
            }
            player.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#7
0
        public override void Created(PlayerTask playerTask)
        {
            Guid opponentId = new Guid(playerTask.data);             // take the opponent id from the temp data value

            // by specifying the data param we avoid unwanted recursion in player task creation
            PlayerTask oppoTask = PlayerTask.CreateTask("prisonersdilemma", opponentId, playerTask.id + ",");

            playerTask.data = oppoTask.id + ",";             // from now on, the data values will be: "{opponent task id},{my chosen state}"
            playerTask.Save();
        }
示例#8
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            if (player.GetTeam.GetPlayers.Max(o => o.Rank) == player.Rank)
            {
                // highest ranked just drinks it
                player.RemoveItem("coffee");
                player.Rank += 7;
                player.Save();

                player.GetTeam.score += 16;
                player.GetTeam.Save();

                playerTask.State = Task.TaskState.Completed;
                playerTask.Save();

                return;
            }

            Player transferPlayer = Player.Load(form["data"]);

            if (transferPlayer == null || transferPlayer.Rank < player.Rank || transferPlayer.teamId != player.teamId)
            {
                return;
            }

            player.RemoveItem("coffee");
            player.Rank += 7;
            player.Save();

            transferPlayer.AddItem("coffee");
            transferPlayer.Rank += 3;
            transferPlayer.Save();
            transferPlayer.GenerateNewAgentCode();

            player.GetTeam.score += 8;
            player.GetTeam.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#9
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.idle       = false;
            player.IdleUpdate = null;
            player.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#10
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            if (form["data"] == playerTask.data.Substring(0, 4))
            {
                Player player = Player.Load(playerTask.playerId);
                player.Rank += 13;
                player.Save();
            }
        }
示例#11
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            if (player.GetTeam.GetPlayers.Min(o => o.Rank) == player.Rank)
            {
                // lowest rank just does it
                player.Rank += 9;
                player.Save();

                player.GetTeam.score += 8;
                player.GetTeam.Save();

                playerTask.State = Task.TaskState.Completed;
                playerTask.Save();

                return;
            }

            Player transferPlayer = Player.Load(form["data"]);

            if (transferPlayer == null || transferPlayer.Rank > player.Rank)
            {
                return;
            }

            player.Rank += 8;
            player.Save();

            PlayerTask.CreateTask("delegatedown", transferPlayer.id);
            transferPlayer.GenerateNewAgentCode();

            player.GetTeam.score += 5;
            player.GetTeam.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#12
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            if (form["check"] != null)
            {
                playerTask.data = form["check"];
                playerTask.Save();
                return;
            }

            if (form["data"] == null)
            {
                return;
            }

            Player recommendedPlayer = Player.Load(form["data"]);

            if (recommendedPlayer == null)
            {
                return;
            }

            recommendedPlayer.Rank += 15;
            recommendedPlayer.Save();
            Notification.CreatePlayer("The <b>" + player.GetTeam.name + "</b> is happy to present you with this coveted Award of Recognition and a commensurate increase in your role within the company. Finally.", recommendedPlayer.id);
            recommendedPlayer.GenerateNewAgentCode();

            player.Rank += 7;
            player.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            Newsfeed.Create("<b>" + player.GetTeam.name + "</b> has issued an Award of Recognition to <b>" + recommendedPlayer.Name + "</b>. Thanks for all your hard work!", Newsfeed.Context.success);
        }
示例#13
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            if (form["data"] != playerTask.data.Split(',')[1])
            {
                return;
            }

            Player player = Player.Load(playerTask.playerId);

            player.Rank += 12;
            player.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#14
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            PlayerItem acquiredItem = PlayerItem.Load(form["data"]);

            acquiredItem.Delete();
            player.AddItem(acquiredItem.itemId);

            player.Rank += 9;
            player.Save();
        }
示例#15
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            if (form["itemId"] != null)
            {
                Item item = player.GetTeam.WarehouseRetrieveItem(form["itemId"]);
                player.AddItem(item.id);

                player.Rank += 9;
                player.Save();
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#16
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.Rank += 12;
            player.Save();

            player.GetTeam.score += 9;
            player.GetTeam.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            player.RemoveItem("egg");
            player.AddItem("albumen");
        }
示例#17
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.Rank += 9;
            player.Save();

            player.GetTeam.score += 5;
            player.GetTeam.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            Item startItem = player.GiveRandomItem(1).GetItem;

            Notification.CreatePlayer("Welcome to the <b>" + player.GetTeam.name + "</b> team, agent <b>" + player.Name + "</b>. We've given you this <b>" + startItem.name + "</b> to help get you started.", player.id);
        }
示例#18
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            if (form["data"] == PlayerItem.Load(Convert.ToInt32(playerTask.data)).TransferCode)
            {
                player.Rank += 13;
                player.Save();

                PlayerItem itemToRetrieve = PlayerItem.Load(Convert.ToInt32(playerTask.data));
                player.AddItem(itemToRetrieve.itemId);
                itemToRetrieve.Delete();
            }
        }
示例#19
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            player.Rank += 12;
            player.Save();

            Player targetPlayer = Player.Load(new Guid(playerTask.data));
            Item   item         = Item.Load(form["itemId"]);

            targetPlayer.AddItem(item.id);
            targetPlayer.Rank += 10;
            targetPlayer.Save();

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#20
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            int xres = Convert.ToInt32(playerTask.data.Split(',')[1]);
            int yres = Convert.ToInt32(playerTask.data.Split(',')[2]);

            player.Rank += (xres * yres);
            player.Save();

            if (player.AvailableItemSlots >= 1)
            {
                player.GiveRandomItem(1);
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#21
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            int recursionLevel = Convert.ToInt32(form["recursionLevel"]);

            if (recursionLevel == 0)
            {
                return;                                  // not enough recursion
            }
            if (recursionLevel < 3)
            {
                player.Rank += recursionLevel;
                player.Save();
                Notification.CreatePlayer("That really wasn't that much recursion.", player.id);
            }
            else if (recursionLevel < 6)
            {
                player.Rank += recursionLevel;
                player.Save();
                player.GetTeam.score += recursionLevel;
                player.GetTeam.Save();
                Notification.CreatePlayer("That was a reasonable amount of recursion.", player.id);
            }
            else if (recursionLevel < 9)
            {
                player.Rank += recursionLevel;
                player.Save();
                player.GetTeam.score += recursionLevel;
                player.GetTeam.Save();
                Notification.CreatePlayer("That was rather a lot of recursion.", player.id);
            }
            else
            {
                player.Rank += 10;
                player.Save();
                player.GetTeam.score += 10;
                player.GetTeam.Save();
                Notification.CreatePlayer("That was an absurd amount of recursion.", player.id);
            }

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }
示例#22
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();

            player.Rank += 6;
            player.Save();

            // action: "trade", itemId: $(".modal #itemId").val()
            if (form["action"] == "trade")
            {
                PlayerItem tradedItem = PlayerItem.Load(Convert.ToInt32(form["itemId"]));
                tradedItem.Delete();

                player.AddItem(playerTask.data);
            }
        }
示例#23
0
        public override void UpdateTask(PlayerTask playerTask, System.Web.Mvc.FormCollection form)
        {
            Player player = Player.Load(playerTask.playerId);

            // all players on other teams with items (non-unique, 2 or smaller)
            int maxSize          = Math.Max(2, player.AvailableItemSlots);
            var playersWithItems = Team.GetAll().Where(o => o.id != playerTask.GetPlayer.teamId).SelectMany(o => o.GetPlayers).Where(o => o.GetItems.Count(i => i.GetItem.size <= maxSize && !i.GetItem.unique) > 0).ToList();

            if (player.AvailableItemSlots < 1)
            {
                // do nothing, I guess
            }
            else if (playersWithItems.Count == 0)
            {
                // no one to steal from, so just give them an item
                player.GiveRandomItem(1);
            }
            else
            {
                Player victim        = playersWithItems[HGameApp.Rnd.Next(playersWithItems.Count)];
                var    possibleItems = victim.GetItems.Where(o => o.GetItem.size <= maxSize).ToList();
                var    victimItem    = possibleItems[HGameApp.Rnd.Next(possibleItems.Count)];

                player.AddItem(victimItem.itemId);

                victimItem.Delete();
                Notification.CreatePlayer("Your <b>" + victimItem.GetItem.name + "</b> dissappears under mysterious circumstances.", victim.id);

                // 20% of the time just stop
                if (HGameApp.Rnd.Next(100) > 20)
                {
                    PlayerTask.CreateTask("buttonunit", victim.id);
                }
            }

            Notification.CreatePlayer("The strange man returns, reclaims the Button Unit, and explains that it will be offered to someone whom you don't know.", player.id);

            playerTask.State = Task.TaskState.Completed;
            playerTask.Save();
        }