Exemple #1
0
        public static void GenerateFrags(DemoParser parser)
        {
            Dictionary <string, Player> AllPlayers = new Dictionary <string, Player>();
            List <Death> deaths       = new List <Death>();
            var          outputStream = new StreamWriter("round.txt");

            float timeBeginningRound = 0f;

            parser.ParseHeader();

            string   mapName = parser.Map;
            Map_JSON map     = new Map_JSON();

            // Get information from the assoiated JSON file.
            try {
                map = JsonConvert.DeserializeObject <Map_JSON>(File.ReadAllText("Maps_json/" + mapName + ".json"));
            } catch (FileNotFoundException) {
                Console.WriteLine("File was not found {0}", mapName);
                System.Environment.Exit(1);
            }

            int numberCT = 5;
            int numberT  = 5;

            outputStream.WriteLine(parser.Map);

            // Make a print on round-start so you can see the actual frags per round.
            parser.RoundStart += (sender, e) => {
                timeBeginningRound = parser.CurrentTime;
                outputStream.WriteLine("Round {0}", parser.CTScore + parser.TScore);
                // Console.WriteLine("New Round, Current Score: T {0} : {1} CT", parser.TScore, parser.CTScore);

                numberCT = 5;
                numberT  = 5;

                AllPlayers = new Dictionary <string, Player>();
                deaths     = new List <Death>();

                //foreach (var player in parser.PlayingParticipants) {
                //    AllPlayers.Add(player.Name, new Player(player.Name, player.Position, player.Position,
                //        player.ActiveWeapon.AmmoInMagazine, player.ActiveWeapon.Weapon));
                //}
            };

            parser.PlayerKilled += (sender, e) => {
                if (e.Killer == null)
                {
                    // The player has murdered himself (falling / own nade / ...)
                    Console.WriteLine("<World><0><None>");
                }
                else
                {
                    Console.Write("<{0}><{1}> killed ", e.Killer.Name, ShortTeam(e.Killer.Team));
                }

                if (e.Assister == null)
                {
                    // nothing
                }
                else
                {
                    Console.Write(" + <{0}><{1}> assist ", e.Assister.Name, ShortTeam(e.Assister.Team));
                }

                Console.Write(" [{0}]", e.Weapon.Weapon);

                if (e.Headshot)
                {
                    Console.Write("[HS]");
                }

                if (e.PenetratedObjects > 0)
                {
                    Console.Write("[Wall]");
                }

                Console.Write(" ");

                Console.Write(" <{0}><{1}>", e.Victim.Name, ShortTeam(e.Victim.Team));
                Console.Write(" Weapon {0} Ammo in Magazine {1} {2}", e.Victim.ActiveWeapon.Weapon,
                              e.Victim.ActiveWeapon.AmmoInMagazine.ToString(),
                              e.Victim.ActiveWeapon.AmmoInMagazine == WeaponInfo.WeaponAmmoMagazine(e.Victim.ActiveWeapon.Weapon) ?
                              "Ammo Max" : "");

                if (BackStabbing(e))
                {
                    Console.Write("  Not Looking player");
                }
                else
                {
                    Console.Write("  LookingPlayer");
                }

                if (e.Victim.Team == Team.CounterTerrorist)
                {
                    numberCT--;
                }
                else
                {
                    numberT--;
                }

                Console.WriteLine();
                WriteToFileDeadPlayers(outputStream, AllPlayers[e.Victim.Name]);
                deaths.Add(new Death(GetPositionMiniMap(e.Victim.Position, map.pos_x, map.pos_y, map.scale), e.Victim.Team));
            };

            parser.RoundEnd += (sender, e) => {
                Console.WriteLine("NumberCT alive " + numberCT.ToString() + " Number T alive " + numberT.ToString());
                Console.WriteLine();

                GenerateHeatMaps.GenerateMap(deaths, parser.CTScore + parser.TScore);
            };

            parser.TickDone += (sender, e) => {
                float currentTime = parser.CurrentTime - timeBeginningRound;

                // Updated every frame
                foreach (var player in parser.PlayingParticipants)
                {
                    // We multiply it by the time of one tick
                    // Since the velocity is given in
                    // ingame-units per second
                    // Console.WriteLine("{0} {1}", player.Name, player.Position);
                    if (AllPlayers.ContainsKey(player.Name))
                    {
                        Player current = AllPlayers[player.Name];
                        //if (player.IsAlive) {
                        //    current.Update(player.Position, player.ActiveWeapon.AmmoInMagazine);
                        //}
                    }
                    else
                    {
                        AllPlayers.Add(player.Name, new Player(player.Name, player.Position, player.Position,
                                                               player.ActiveWeapon.AmmoInMagazine, player.ActiveWeapon.Weapon, player.Team,
                                                               (player.Team == Team.CounterTerrorist) ? parser.CTClanName : parser.TClanName));
                    }
                }
            };

            parser.ParseToEnd();
            outputStream.Close();
        }
Exemple #2
0
 public Player GetLoggedPlayer(string clientUsername)
 {
     return(AllPlayers.Find(p => p.Client.Username.Equals(clientUsername)));
 }
        public void TestSpellRangeTest()
        {
            Spell chaosBolt = AllSpells.Get(SpellNames.ChaosBolt);

            AllPlayers.Invalidate();
            AllFeatures.Invalidate();
            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            Character sorcerer = PlayerHelper.GetPlayerAtLevel("Sorcerer", 6);

            sorcerer.name = "Mark";
            game.AddPlayer(sorcerer);
            Monster joe = MonsterBuilder.BuildVineBlight("Joe");

            game.AddCreature(joe);
            game.Start();

            PositionCreatures(@"
┌───────────────┐
│               │
│               │
│           M   │
│               │
│               └───────────────┐
│                               │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           J   │
│               │
│               │
│               │
│               │
└───────────────┘", game.AllCreatures);
            Assert.AreEqual(40, sorcerer.CanCast(chaosBolt).DistanceTo(joe));
            Assert.IsTrue(sorcerer.CanCast(chaosBolt).At(joe));


            PositionCreatures(@"
┌───────────────┐
│               │
│               │
│           M   │
│               │
│               └───────────────┐
│                               │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                                       │
│                               │
│                               │
│               ┌───────────────┘
│           J   │
│               │
│               │
│               │
│               │
└───────────────┘", game.AllCreatures);

            Assert.AreEqual(125, sorcerer.CanCast(chaosBolt).DistanceTo(joe));
            Assert.IsFalse(sorcerer.CanCast(chaosBolt).At(joe));
        }
 public AnalyticsSubmitter(DefusingState defusingState, AllPlayers allPlayers)
 {
     _defusingState = defusingState;
     _allPlayers    = allPlayers;
 }
 public Player GetPlayer(PlayerId id) => AllPlayers.Find(p => p.Id == id);
Exemple #6
0
 public List <string> RefreshWaitingPlayers(string nickName)
 {
     return(AllPlayers.Where(pair => pair.Key != nickName).Select(pair => pair.Value.Playing ? "#" + pair.Key : pair.Key).ToList());
 }
Exemple #7
0
 public GetAllPlayers(AllPlayers allPlayers)
 {
     _allPlayers = allPlayers;
 }
Exemple #8
0
        public ModdedPlayerClass ModdedPlayerById(byte id)
        {
            List <ModdedPlayerClass> matches = AllPlayers.FindAll(player => player._Object.PlayerId == id);

            return(matches.FirstOrDefault());
        }
Exemple #9
0
    private void Update()
    {
        if (Current_Player_ID == My_Profile.UserName)
        {
        }
        else
        {
        }
        if (paintingslider)
        {
            paintingslider.value -= Time.deltaTime;
        }
        if (My_Profile.IsMasterClient)
        {
            if (PhotonNetwork.CurrentRoom.PlayerCount == 1 || PhotonNetwork.CurrentRoom.PlayerCount == 0)
            {
                //Just One Player Stay Here Please Win
            }
            if (state == CurrentState.None)
            {
                photonView.RPC("SetCurrentPlayer", RpcTarget.AllBuffered, "0");
                state = CurrentState.WaitingforChoose;
                Debug.Log(state);
            }
            else if (state == CurrentState.WaitingforChoose)
            {
                photonView.RPC("ResetButtons", RpcTarget.AllBuffered);
                answerindex = 0;
                photonView.RPC("DeletePainting", RpcTarget.AllBufferedViaServer);
                photonView.RPC("roundplus", RpcTarget.AllBuffered);
                istimetoPaint  = false;
                istimetoChoose = false;
                photonView.RPC("ActiveSelectionPanel", RpcTarget.AllBuffered, Current_Player_ID, "0");
                photonView.RPC("Active_WaitingforChoose_Panel", RpcTarget.AllBuffered, true);
                state = CurrentState.Empty;
                StartCoroutine(SetRPCCall("SetCurrentPlayer", 2, ""));
                Debug.Log(state);
                waitingtimeforpaint = waitingtimeforpaintindex;
            }
            else if (state == CurrentState.WaitingForSelect)
            {
                Saved_Time     = (int)PhotonNetwork.Time;
                istimetoChoose = true;
                photonView.RPC("ActiveSelectionPanel", RpcTarget.AllBuffered, Current_Player_ID, "1");
                photonView.RPC("Active_WaitingforChoose_Panel", RpcTarget.AllBuffered, false);
                state = CurrentState.Empty;
                CalculatingChoosingTime(Current_Player_ID);
                Debug.Log(state);
            }
            else if (state == CurrentState.inGame)
            {
                photonView.RPC("InitTheBoxes", RpcTarget.AllBuffered);
                photonView.RPC("ResetTimeSlider", RpcTarget.AllBuffered);
                Saved_Time = (int)PhotonNetwork.Time;



                istimetoPaint  = true;
                istimetoChoose = false;
                state          = CurrentState.Empty;
                Debug.Log(state);
                //Game is On the Road
                photonView.RPC("InGamePublic", RpcTarget.AllBuffered);
            }
            else if (state == CurrentState.TimeHasFinish)
            {
                istimetoPaint  = false;
                istimetoChoose = false;
                photonView.RPC("ScoreBoardInit", RpcTarget.AllBuffered);
                //state = CurrentState.WaitingforChoose;
                Debug.Log(state);
                //Players Time Has Finished
                //Current Word is ...
                state = CurrentState.Empty;
            }
            else if (state == CurrentState.NextRound)
            {
                if (GameMode_String == "Round")
                {
                    if (CurrentRound <= MaxRound)
                    {
                        state = CurrentState.WaitingforChoose;
                    }
                    else
                    {
                        state = CurrentState.EndGame;
                    }
                }
                else if (GameMode_String == "Score")
                {
                    foreach (var player in PlayersScore)
                    {
                        if (player.score < 20)
                        {
                            state = CurrentState.WaitingforChoose;
                        }
                        else
                        {
                            state = CurrentState.EndGame;
                            return;
                        }
                    }
                }
                else if (GameMode_String == "Time")
                {
                    if ((int)PhotonNetwork.Time <= Played_Time + 30)
                    {
                        state = CurrentState.WaitingforChoose;
                    }
                    else
                    {
                        state = CurrentState.EndGame;
                    }
                }
                else if (GameMode_String == "Hads")
                {
                    if (CurrentRound <= MaxRound)
                    {
                        state = CurrentState.WaitingforChoose;
                    }
                    else
                    {
                        state = CurrentState.EndGame;
                    }
                }
                Debug.Log(state);

                //Next Round is started
                //Lets Go to  state = CurrentState.WaitingforChoose;
            }
            else if (state == CurrentState.EndGame)
            {
                Debug.Log(state);
                photonView.RPC("Final_Win", RpcTarget.All);
                state = CurrentState.Empty;
            }
            if (istimetoChoose && state == CurrentState.Empty)
            {
                if ((int)PhotonNetwork.Time == Saved_Time + waitingtimeforchoose)
                {
                    state = CurrentState.WaitingforChoose;
                }
            }
            if (istimetoPaint && state == CurrentState.Empty)
            {
                if (((int)PhotonNetwork.Time == Saved_Time + waitingtimeforpaint) || answerindex == PlayersList.Count)
                {
                    state = CurrentState.TimeHasFinish;
                }
                //state = CurrentState.TimeHasFinish;
            }
        }
        if (Current_Player_ID == "0")
        {
            //Waiting For Server to Choosing a Player
        }
        else if (Current_Player_ID == "1")
        {
            //Next Round is Starting
        }
        time_TXT.text = (PhotonNetwork.Time).ToString();

        if (My_Profile == null)
        {
            Debug.LogError("ERROR IN PLAYERID");
            return;
        }


        if (!DoListsMatch(PlayersList, AllPlayers))
        {
            //SomePlayers Are Left The Game
            // Debug.LogWarning("SomePlayers Are Left The Game");
            foreach (var online in PhotonNetwork.CurrentRoom.Players)
            {
                if (!AllPlayers.Contains(online.Value.NickName))
                {
                    Debug.Log(AllPlayers + "Left the Room");
                }
            }
        }

        #region Sliders
        if (WaitingForSelect_SelectionPanel.active == true)
        {
            choosingslider.value -= Time.deltaTime;
        }
        else
        {
            choosingslider.value = 10;
        }

        if (WaitingForSelect_Panel.active == true)
        {
            waitingslider.value  -= Time.deltaTime;
            Waiting_Text_TXT.text = "Waiting For " + Current_Player_ID + " To Choose a Word";
        }
        else
        {
            waitingslider.value = 10;
        }

        #endregion
        if (NumberofPlayers != PhotonNetwork.CurrentRoom.PlayerCount)
        {
            PlayersList.Clear();
            foreach (var player in PhotonNetwork.CurrentRoom.Players)
            {
                PlayersList.Add(player.Value.NickName);
            }
            NumberofPlayers = PhotonNetwork.CurrentRoom.PlayerCount;
        }
    }
        protected override void PageLoaded()
        {
            if (_isWasTransitionToAddPage)
            {
                _isWasTransitionToAddPage = false;
                if (Players.Count > _lastSizePlayers)
                {
                    // приводим добавленного игрока к типу AllPlayers
                    var addedPlayer = new AllPlayers(Players.Last(), false, true, false);
                    Players.Remove(Players.Last());

                    var q = _poker.GetPlayers();
                    q.Add(addedPlayer);
                    var sort = q.OrderBy(x => x.Name).ToList();
                    var index = sort.IndexOf(addedPlayer);
                    Players.Insert(index, addedPlayer);
                }
            }

            if (Appbar != null)
                return;

            Appbar = GetService<IApplicationBarService>();
            Appbar.AddButton(AppResources.Check, CheckPath, SaveClick);
            Appbar.AddButton(AppResources.Cancel, CancelPath , CancelClick);
            Appbar.AddButton(AppResources.Add, AddPath , add_Click);
        }
 public PlayerConfig FindPlayer(string key) => AllPlayers.First(p => p.key == key);
Exemple #12
0
 static MultiClassTests()
 {
     Folders.UseTestData = true;
     AllPlayers.Invalidate();
 }
Exemple #13
0
        // The main play function, which assumes there are enough players to play (work in progress!!!)
        public async Task PlayGame(CommandContext ctx, DiscordChannel voice)
        {
            CurrentCurePosition++; // CurrentCurePosition is now 0
            Round++;               // round is now 1
            VoiceChannel = voice;

            // Add the users in the current voice channel
            foreach (DiscordMember m in VoiceChannel.Users)
            {
                AllPlayers.Add(m, -1);
            }

            GenerateTeam();
            GenerateCure(true);

            string T1 = "**Team1:** ";
            string T2 = "**Team2:** ";

            foreach (DiscordMember m in Team1)
            {
                T1 += $"{m.DisplayName} ";
            }
            T1.TrimEnd(' ');
            foreach (DiscordMember m in Team2)
            {
                T2 += $"{m.DisplayName} ";
            }
            T2.TrimEnd(' ');

            // Send an embedded message describing the teams
            await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder
            {
                Title       = $"<Welcome to Pandemic Panic!>",
                Description = $"As a deadly disease ravages the globe, you and your team of scientists must work together to find The Cure.\n" +
                              $"You will be split into two teams, each with an even number of people. During each round, one person from each team " +
                              $"will be chosen as the Head Scientist, who must coordinate their team to find a word that represents the next part of The Cure.\n" +
                              $"Guess the word before the other team and you win the round! The first to guess three words wins!\n" +
                              $"__**Be sure to check your DMs for rules of each round**__ (click the discord icon on the top left and look in your messages).\n" +
                              $"If you have a guess and are on the answering side, submit your answer with\n**!c ANSWER** in the chat. All words are singular.",
                Color = DiscordColor.Aquamarine
            }.Build());

            // Send an embedded message describing the teams
            await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder
            {
                Title       = $"<TEAM FORMATIONS>",
                Description = $"{T1}\n{T2}",
                Color       = DiscordColor.Aquamarine
            }.Build());

            // Starts pre-game timer (for players to get their bearings ~30 seconds)
            Console.WriteLine("Pre-game timer started.");

            StartGenericTimer(ctx,
                              " before game starts.",
                              "The game is now starting.", 30);
            GenericTimerActive = true;

            while (GenericTimerActive)
            {
            }   // Blocks until Intermission ends

            Console.WriteLine("Pre-game period ended.");

            // Stop when either team has a score of MaxRounds (default: 3-1 = 2)
            while (Team1Score < (MaxRounds - 1) && Team2Score < (MaxRounds - 1))
            {
                PickMinigame();

                // Choose the head scientists
                PickHeadScientists(); // comment this if you're testing with only one person

                PickRoundColor();

                // Move everyone into seperate channels
                DiscordChannel T1Channel = await ctx.Guild.CreateChannelAsync("TEAM 1", DSharpPlus.ChannelType.Voice, VoiceChannel.Parent);

                DiscordChannel T2Channel = await ctx.Guild.CreateChannelAsync("TEAM 2", DSharpPlus.ChannelType.Voice, VoiceChannel.Parent);

                foreach (DiscordMember m in VoiceChannel.Users)
                {
                    int ChannelNum = AllPlayers[m];
                    Console.WriteLine($"Moving member: {m.DisplayName} to Team channel {ChannelNum}");
                    if (AllPlayers[m] == 1)
                    {
                        await T1Channel.PlaceMemberAsync(m);
                    }
                    else if (AllPlayers[m] == 2)
                    {
                        await T2Channel.PlaceMemberAsync(m);
                    }
                }

                Console.WriteLine("Distributing info");

                // Send an embedded message describing the minigame and the round
                await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder
                {
                    Title       = $"<Round: {Round} | Category: {NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}>",
                    Description = $"__Gamemode: {CurrentMinigame.Name}__\n" +
                                  $"**Team 1's head scientist:** {Team1Lead.Mention}\n" + //comment the following if testing with only one person
                                  $"**Team 2's head scientist:** {Team2Lead.Mention}\n" + //comment the following if testing with only one person
                                  CurrentMinigame.Description,
                    Color = LastColorUsed
                }.Build());

                // Distribute infomation and instructions for each player
                foreach (DiscordMember m in AllPlayers.Keys)
                {
                    // Determine who recieves what information with CurrentMinigame.WhoHasInfo and CurrentMinigame.TypeOfInfo
                    if (m == Team1Lead)
                    {
                        // Team1 Head scientist
                        if (CurrentMinigame.WhoHasInfo == InfoShare.HeadScientist)
                        {
                            // Team1 Head scientist have information
                            if (CurrentMinigame.TypeOfInfo == InfoType.Chat)
                            {
                                // Team1 Head scientist have information (chat)
                                await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                {
                                    Title       = $"You are Team1's head scientist. Your word is '{Cure[CurrentCurePosition].Item1}'",
                                    Description = CurrentMinigame.InformedInstructions,
                                    Color       = LastColorUsed
                                }.Build());
                            }
                            else if (CurrentMinigame.TypeOfInfo == InfoType.Image)
                            {
                                // Team1 Head scientist have information (image)
                                await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                {
                                    Title = $"You are Team1's head scientist. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" +
                                            " associated with the image below",
                                    Description = CurrentMinigame.InformedInstructions,
                                    Color       = LastColorUsed
                                }.Build());

                                await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1));
                            }
                        }
                        else if (CurrentMinigame.WhoHasInfo == InfoShare.RegularScientists)
                        {
                            // Team1 Head scientist don't have information
                            await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                            {
                                Title       = $"You are Team1's head scientist.",
                                Description = CurrentMinigame.UninformedInstructions,
                                Color       = LastColorUsed
                            }.Build());
                        }
                    }
                    else if (m == Team2Lead)
                    {
                        // Team2 Head scientist
                        if (CurrentMinigame.WhoHasInfo == InfoShare.HeadScientist)
                        {
                            // Team2 Head scientist have information
                            if (CurrentMinigame.TypeOfInfo == InfoType.Chat)
                            {
                                // Team2 Head scientist have information (chat)
                                await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                {
                                    Title       = $"You are Team2's head scientist. Your word is '{Cure[CurrentCurePosition].Item1}'",
                                    Description = CurrentMinigame.InformedInstructions,
                                    Color       = LastColorUsed
                                }.Build());
                            }
                            else if (CurrentMinigame.TypeOfInfo == InfoType.Image)
                            {
                                // Team2 Head scientist have information (image)
                                await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                {
                                    Title = $"You are Team2's head scientist. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" +
                                            " associated with the image below",
                                    Description = CurrentMinigame.InformedInstructions,
                                    Color       = LastColorUsed
                                }.Build());

                                await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1));
                            }
                        }
                        else if (CurrentMinigame.WhoHasInfo == InfoShare.RegularScientists)
                        {
                            // Team2 Head scientist doesn't have information
                            await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                            {
                                Title       = $"You are Team2's head scientist.",
                                Description = CurrentMinigame.UninformedInstructions,
                                Color       = LastColorUsed
                            }.Build());
                        }
                    }
                    else
                    {
                        // Regular scientist
                        if (CurrentMinigame.WhoHasInfo == InfoShare.HeadScientist)
                        {
                            // Regular scientist doesn't have info
                            await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                            {
                                Title       = $"You are a regular scientist on Team {AllPlayers[m]}.",
                                Description = CurrentMinigame.UninformedInstructions,
                                Color       = LastColorUsed
                            }.Build());
                        }
                        else if (CurrentMinigame.WhoHasInfo == InfoShare.RegularScientists)
                        {
                            if (AllPlayers[m] == 1 && m != Team1Lead)
                            {
                                // Regular scientist in team 1 have info
                                if (CurrentMinigame.TypeOfInfo == InfoType.Chat)
                                {
                                    // Regular scientist in team 1 have info (chat)
                                    await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                    {
                                        Title       = $"You are one of Team1's many scientists. Your word is '{Cure[CurrentCurePosition].Item1}'",
                                        Description = CurrentMinigame.InformedInstructions,
                                        Color       = LastColorUsed
                                    }.Build());
                                }
                                else if (CurrentMinigame.TypeOfInfo == InfoType.Image)
                                {
                                    // Regular scientist in team 1 have info (image)
                                    await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                    {
                                        Title = $"You are one of Team1's many scientists. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" +
                                                " associated with the image below",
                                        Description = CurrentMinigame.InformedInstructions,
                                        Color       = LastColorUsed
                                    }.Build());

                                    await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1));
                                }
                            }
                            else if (AllPlayers[m] == 2 && m != Team2Lead)
                            {
                                // Regular scientist in team 2 have info
                                if (CurrentMinigame.TypeOfInfo == InfoType.Chat)
                                {
                                    // Regular scientist in team 2 have info (chat)
                                    await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                    {
                                        Title       = $"You are one of Team2's many scientists. Your word is '{Cure[CurrentCurePosition].Item1}'",
                                        Description = CurrentMinigame.InformedInstructions,
                                        Color       = LastColorUsed
                                    }.Build());
                                }
                                else if (CurrentMinigame.TypeOfInfo == InfoType.Image)
                                {
                                    // Regular scientist in team 2 have info (image)
                                    await m.SendMessageAsync(embed : new DiscordEmbedBuilder
                                    {
                                        Title = $"You are one of Team2's many scientists. Your word ({NounClass.TypeOfWord(Cure[CurrentCurePosition].Item2)}) is" +
                                                " associated with the image below",
                                        Description = CurrentMinigame.InformedInstructions,
                                        Color       = LastColorUsed
                                    }.Build());

                                    await m.SendFileAsync(NounClass.FetchImagePath(Cure[CurrentCurePosition].Item1));
                                }
                            }
                        }
                    }
                }

                Console.WriteLine("Finished distributing info");

                // Starts Instruction timer (for players to get their bearings ... ~60 seconds)
                Console.WriteLine("Instruction timer started.");

                StartGenericTimer(ctx,
                                  "seconds remaining to read your instructions.",
                                  "The round is now starting.",
                                  60);
                GenericTimerActive = true;

                while (GenericTimerActive)
                {
                }   // Blocks until Intermission ends

                Console.WriteLine("Instruction period ended.");

                // Starts Round timer
                Console.WriteLine("Round timer started.");
                StartRoundTimer(ctx);
                RoundResult     = 0;
                RoundInProgress = true;

                while (RoundInProgress)
                {
                }   // Blocks until round ends

                if (RoundResult == 0)
                {
                    // We resetted the game, just return here.
                    Console.WriteLine("Finishing one game abruptly.");
                    return;
                }
                else if (RoundResult == -1)
                {
                    // Tie round
                    Console.WriteLine("Round ended with a tie.\nGenerating new but similar cures for the next round.");
                    NextRoundTIE();
                }
                else if (RoundResult != 0)
                {
                    // Update the values, then print a message
                    if (RoundResult == 1)
                    {
                        await NextRoundWIN(ctx, true);
                    }
                    else
                    {
                        await NextRoundWIN(ctx, false);
                    }
                }

                // Move everyone back into the same voice channel
                foreach (DiscordMember m in T1Channel.Users)
                {
                    Console.WriteLine($"Moving member: {m.DisplayName} to back to main voice channel");
                    await VoiceChannel.PlaceMemberAsync(m);
                }
                foreach (DiscordMember m in T2Channel.Users)
                {
                    Console.WriteLine($"Moving member: {m.DisplayName} to back to main voice channel");
                    await VoiceChannel.PlaceMemberAsync(m);
                }

                // Delete the old voice channels
                foreach (DiscordChannel d in ctx.Guild.Channels.Values)
                {
                    // If the channel's parent belong to the voice channel
                    if (d.Parent != null && d.Parent.Name == "Voice Channels")
                    {
                        if (d.Name.StartsWith("TEAM"))
                        {
                            await d.DeleteAsync("Deleting TEAM channel.");
                        }
                    }
                }

                // Starts Intermission timer
                Console.WriteLine("Intermission timer started.");
                StartGenericTimer(ctx,
                                  "seconds remaining for this intermission.",
                                  "Intermission is over.", 20); // debug was 15
                GenericTimerActive = true;

                while (GenericTimerActive)
                {
                }   // Blocks until Intermission ends

                Console.WriteLine("Intermission ended.");
            }

            string TitleMessage;

            if (Team1Score >= (MaxRounds - 1))
            {
                TitleMessage = "GAMEOVER. Team 1 wins!";
            }
            else
            {
                TitleMessage = "GAMEOVER. Team 2 wins!";
            }
            await ctx.Channel.SendMessageAsync(embed : new DiscordEmbedBuilder
            {
                Title       = TitleMessage,
                Description = $"__Current scores:__ **Team1: {Team1Score} | Team2: {Team2Score}**\n" +
                              $"__The cure was:__ {GetCure()}",
                Color = LastColorUsed
            }.Build());

            await ctx.Channel.SendMessageAsync("The game is now over, type !sg while in a voice channel with at least 4 players to start a new game!");

            StopGame();
        }
Exemple #14
0
        public ModdedPlayerClass GetLocalModdedPlayer()
        {
            List <ModdedPlayerClass> matches = AllPlayers.FindAll(player => player._Object == PlayerControl.LocalPlayer);

            return(matches.FirstOrDefault());
        }
 public void ClearPlayers()
 {
     AllPlayers.Clear();
     zanversePlayerVM = null; //whoops : v)
 }
Exemple #16
0
        public ModdedPlayerClass FindPlayerOfRole(string roleName)
        {
            List <ModdedPlayerClass> matches = AllPlayers.FindAll(player => player.Role != null && player.Role.RoleName == roleName);

            return(matches.FirstOrDefault());
        }
        public static void Prefix([HarmonyArgument(0)] out Il2CppReferenceArray <GameData.PlayerInfo> playerInfos)
        {
            List <Role> assignedRoles = AssignedRoles.Values.ToList();

            foreach (Role r in assignedRoles)
            {
                r.ClearSettings();
            }

            var infected = new List <GameData.PlayerInfo>();
            var roles    = new List <Role>();

            List <Role> availableRoles = Main.Roles.ToList();

            List <RoleSlot>      roleSlots        = Main.GetRoleSlots().ToList();
            List <PlayerControl> availablePlayers = AllPlayers.ToList();

            for (var i = 0; i < roleSlots.Count && availablePlayers.Count > 0; i++)
            {
                RoleSlot           roleSlot         = roleSlots[i];
                var                spawnChance      = 0;
                IEnumerable <Role> possibleRoles    = roleSlot.GetFittingRoles(availableRoles);
                var                roleSpawnChances = new List <RoleSpawnChancePair>();
                foreach (Role possibleRole in possibleRoles)
                {
                    roleSpawnChances.Add(new RoleSpawnChancePair(possibleRole,
                                                                 spawnChance += (int)Main.GetRoleSpawnChance(possibleRole.GetType())));
                }

                // IEnumerable<RoleSpawnChancePair> roleSpawnChances = roleSlot.GetFittingRoles(availableRoles).Select(role => new RoleSpawnChancePair(role, spawnChance += (int) Main.GetRoleSpawnChance(role.GetType())));
                int spawnValue = Rng.Next(spawnChance);
                foreach (RoleSpawnChancePair roleSpawnChance in roleSpawnChances)
                {
                    if (roleSpawnChance.spawnChance > spawnValue)
                    {
                        roles.Add(roleSpawnChance.role);
                        PlayerControl player = availablePlayers[Rng.Next(availablePlayers.Count)];
                        Role.RpcSetRole(roleSpawnChance.role, player);

                        availableRoles.Remove(roleSpawnChance.role);
                        availablePlayers.Remove(player);
                        if (roleSlots[i].IsInfected)
                        {
                            infected.Add(player.Data);
                        }

                        break;
                    }
                }

                /*
                 * Role role = roleSlots[i].GetRole(ref availableRoles);
                 * PlayerControl player = availablePlayers[Rng.Next(availablePlayers.Count)];
                 * Role.SetRole(role, player);
                 *
                 * availableRoles.Remove(role);
                 * availablePlayers.Remove(player);
                 * if (roleSlots[i].IsInfected)
                 * {
                 *  infected.Add(player.Data);
                 * }
                 */
            }

            foreach (Role role in roles)
            {
                role.InitializeRole();
            }

            int killAbilitiesToAdd = (int)Main.OptionMafiaKillStart - roles.Count(role =>
                                                                                  role.Faction == Faction.Mafia && role.GetAbility <AbilityKill>() != null);

            // TODO: Randomize order of adding killAbilities, so you don't have an advantage if you log into lobby earlier than another one
            for (var i = 0; i < roles.Count && killAbilitiesToAdd > 0; i++)
            {
                Role role = roles[i];
                if (role.Faction != Faction.Mafia || role.GetAbility <AbilityKill>() != null)
                {
                    continue;
                }

                role.AddAbility <Mafioso, AbilityKill>(true);
                WriteRPC(RPC.AddKillAbility, role.Owner.PlayerId);
                killAbilitiesToAdd--;
            }

            playerInfos = new Il2CppReferenceArray <GameData.PlayerInfo>(infected.ToArray());
        }
Exemple #18
0
        public void TestWrathfulSmite()
        {
            AllPlayers.Invalidate();
            AllSpells.Invalidate();
            AllActionShortcuts.Invalidate();
            Character            ava        = AllPlayers.GetFromId(PlayerID.Ava);
            PlayerActionShortcut greatsword = ava.GetShortcut("Greatsword");

            Assert.IsNotNull(greatsword);
            Monster joeVineBlight = MonsterBuilder.BuildVineBlight("Joe");

            List <PlayerActionShortcut> wrathfulSmites = AllActionShortcuts.Get(ava.playerID, SpellNames.WrathfulSmite);

            Assert.AreEqual(1, wrathfulSmites.Count);
            PlayerActionShortcut wrathfulSmite = wrathfulSmites[0];

            Assert.IsNotNull(wrathfulSmite);

            DndGame game = DndGame.Instance;

            game.GetReadyToPlay();
            game.AddPlayer(ava);
            game.AddMonster(joeVineBlight);
            DateTime gameStartTime = game.Time;

            game.EnteringCombat();

            ava.Hits(joeVineBlight, greatsword);        // Action. Ava is first to fight.
            ava.Cast(wrathfulSmite.Spell);              // Bonus Action - Wrathful Smite lasts for one minute.
            Assert.IsTrue(ava.SpellIsActive(SpellNames.WrathfulSmite));

            joeVineBlight.Misses(ava, AttackNames.Constrict);

            AvaMeleeMissesJoe();                        // Round 2
            Assert.AreEqual(6, game.SecondsSince(gameStartTime));

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(6, game.SecondsSince(gameStartTime));

            AvaMeleeMissesJoe();                // Round 3
            Assert.AreEqual(12, game.SecondsSince(gameStartTime));

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(12, game.SecondsSince(gameStartTime));

            AvaMeleeMissesJoe();
            Assert.AreEqual(18, game.SecondsSince(gameStartTime));

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(18, game.SecondsSince(gameStartTime));

            //`+++NOW THE HIT....
            ava.Hits(joeVineBlight, greatsword);
            Assert.AreEqual(24, game.SecondsSince(gameStartTime));

            Assert.IsTrue(ava.SpellIsActive(SpellNames.WrathfulSmite));              // Wrathful Smite spell is not yet dispelled, however its impact on attack rolls is done.

            Assert.AreEqual($"Target must make a Wisdom saving throw or be frightened of {ava.name} until the spell ends. As an action, the creature can make a Wisdom check against {ava.name}'s spell save DC ({ava.GetSpellSaveDC()}) to steel its resolve and end this {wrathfulSmite.Spell.Name} spell.", game.lastMessageSentToDungeonMaster);

            joeVineBlight.Misses(ava, AttackNames.Constrict);
            Assert.AreEqual(24, game.SecondsSince(gameStartTime));

            ava.Misses(joeVineBlight, greatsword);              // Advancing Round (Ava's turn again).
            Assert.AreEqual("", ava.additionalDiceThisRoll);    // No more die roll effects.
            Assert.AreEqual("", ava.trailingEffectsThisRoll);
            Assert.AreEqual("", ava.dieRollEffectsThisRoll);
            Assert.AreEqual("", ava.dieRollMessageThisRoll);

            Assert.AreEqual(30, game.SecondsSince(gameStartTime));
            game.AdvanceClock(DndTimeSpan.FromSeconds(30));

            Assert.IsFalse(ava.SpellIsActive(SpellNames.WrathfulSmite));              // Wrathful Smite spell should finally be dispelled.

            void AvaMeleeMissesJoe()
            {
                Assert.AreEqual("", ava.additionalDiceThisRoll);
                Assert.AreEqual("", ava.trailingEffectsThisRoll);
                Assert.AreEqual("", ava.dieRollEffectsThisRoll);
                Assert.AreEqual("", ava.dieRollMessageThisRoll);
                ava.Misses(joeVineBlight, greatsword);                  // Advancing Round (Ava's turn again).
                Assert.AreEqual("1d6(psychic)", ava.additionalDiceThisRoll);
                Assert.AreEqual("Ravens;Spirals", ava.trailingEffectsThisRoll);
                Assert.AreEqual("PaladinSmite", ava.dieRollEffectsThisRoll);
                Assert.AreEqual("Wrathful Smite", ava.dieRollMessageThisRoll);
                Assert.IsTrue(ava.SpellIsActive(SpellNames.WrathfulSmite));
            }
        }
 public static PlayerControl ToPlayerControl(this byte b)
 {
     return(AllPlayers.FirstOrDefault(player => player.PlayerId == b));
 }
Exemple #20
0
 /// <summary>
 /// 設定
 /// </summary>
 /// <param name="table">Table</param>
 /// <param name="all">Allplayers</param>
 public void setup(Table table, AllPlayers all)
 {
     this.table = table;
     this.all   = all;
 }
Exemple #21
0
 public void LeaveSession(string nickName)
 {
     AllPlayers.Remove(nickName);
 }