예제 #1
0
 private void EnsureRaidManager()
 {
     if (!raidManager)
     {
         raidManager = FindObjectOfType <RaidManager>();
     }
 }
        private void raid_list_impl(Context ctx)
        {
            //Generate the list of raids
            var raids = RaidManager.EnumerateRaids()
                        .Select(r => RaidManager.GetRaidData(r))
                        .Where(r => r.HasValue).Select(r => r.Value)
                        .ToList();

            //Check that it's not empty
            if (raids.Count > 0)
            {
                //Go through each raid
                raids.ForEach(r =>
                {
                    //Display the raid
                    Bot.GetBotInstance()
                    .SendSuccessMessage(ctx.message.Channel,
                                        r.description,
                                        $"Roster size: {r.roster.Distinct().Count()}",
                                        $"ID: {r.raid_id} | Local time:", DateTimeOffset.FromUnixTimeSeconds(r.timestamp)
                                        );
                });
            }
            else
            {
                //No raids
                Bot.GetBotInstance()
                .SendSuccessMessage(ctx.message.Channel, "Result:", $"None.");
            }
        }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        if (!settings)
        {
            settings = GetComponent <GameSettings>();
        }
        if (!subEventManager)
        {
            subEventManager = GetComponent <TwitchSubscribeEventManager>();
        }
        if (!subEventManager)
        {
            subEventManager = gameObject.AddComponent <TwitchSubscribeEventManager>();
        }

        commandServer = GetComponent <CommandServer>();

        itemManager     = GetComponent <ItemManager>();
        playerManager   = GetComponent <PlayerManager>();
        chunkManager    = GetComponent <ChunkManager>();
        craftingManager = GetComponent <CraftingManager>();
        raidManager     = GetComponent <RaidManager>();
        arenaController = FindObjectOfType <ArenaController>();


        commandServer.StartServer(this);
    }
예제 #4
0
파일: Encounter.cs 프로젝트: jacoba4/RaidTA
    void SpawnRaid()
    {
        GameObject rm = new GameObject("RaidManager");

        raid_manager           = rm.AddComponent(typeof(RaidManager)) as RaidManager;
        raid_manager.encounter = this;
        SetPlayers();
        AddNewPlayers();
    }
예제 #5
0
 void FightEnded(RaidManager.RaidResult result)
 {
     enemiesData.SetNumberOf(Data.SOLDIERS, 0);
     logger.PutLine(result.EnemysRaidResult());
     pView.RPC("RaidReturned", PhotonTargets.Others, result.Serialize());
     labelEnnemies = IDLE;
     display.SetActive(false);
     CancelInvoke("Fight");
 }
예제 #6
0
        public void raid_add(Context ctx, uint id, [RegexParameter(@"[\S\s]+")] string name, [RegexParameter(@"[\S\s]+")] string roles)
        {
            //Determine if a raid with this ID exists
            var exists = RaidManager.EnumerateRaids().Any(r => r.raid_id == id);

            Precondition.Assert(exists, $"No raid with that id ({id}).");

            //Pass on to the implementation
            this.raid_add_impl(ctx, (int)id, name.Trim(), roles);
        }
예제 #7
0
        public void raid_delete(Context ctx, uint id)
        {
            //Determine if a raid with this ID exists
            var exists = RaidManager.EnumerateRaids().Any(r => r.raid_id == id);

            Precondition.Assert(exists, $"No raid with that id ({id}).");

            //Pass on to the implementation
            this.raid_delete_impl(ctx, (int)id);
        }
예제 #8
0
        public void raid_make_comp(Context ctx, [RegexParameter(@"[\S\s]+")] string name)
        {
            //Get the next raid
            var handle = RaidManager.GetNextRaid();

            //Check if we have one
            Precondition.Assert(handle.HasValue, "No raids up.");

            //Pass on
            this.raid_make_comp(ctx, name, (uint)handle.Value.raid_id);
        }
예제 #9
0
        public void raid_delete(Context ctx)
        {
            //Get the next raid
            var handle = RaidManager.GetNextRaid();

            //Check if we have one
            Precondition.Assert(handle.HasValue, "No raids up.");

            //Pass on
            this.raid_delete(ctx, (uint)handle.Value.raid_id);
        }
        private void raid_leave_impl(Context ctx, RaidHandle handle, Entry e)
        {
            //Remove from the raid
            RaidManager.RemoveRaider(handle, e);

            //Return success
            Bot.GetBotInstance()
            .SendSuccessMessage(ctx.message.Channel,
                                "Success",
                                $"You were removed from the roster."
                                );
        }
예제 #11
0
    public override object Output()
    {
        RaidManager rm = GameObject.Find("RaidManager").GetComponent <RaidManager>();

        if (rm)
        {
            return(rm.RandomPlayerLocation());
        }
        else
        {
            return(null);
        }
    }
예제 #12
0
    public override void Execute()
    {
        if (!CheckInputs())
        {
            return;
        }
        RaidManager rm = GameObject.Find("RaidManager").GetComponent <RaidManager>();

        if (rm)
        {
            rm.DamageRaid((int)input_a.Output());
        }
        base.Execute();
    }
        private void raid_create_impl(Context ctx, int day, int month, int year, int hours, int minutes, int offset, string description)
        {
            //Get the date
            var date = new DateTimeOffset(year, month, day, hours, minutes, 0, new TimeSpan(offset, 0, 0));

            //Create the raid
            var handle = RaidManager.CreateRaid(ctx.message.Author.Id, date, description).Value;

            //Return success
            Bot.GetBotInstance()
            .SendSuccessMessage(ctx.message.Channel,
                                "Success",
                                $"Raid has been created.",
                                $"ID: {handle.raid_id} | Local time:", date
                                );
        }
예제 #14
0
        public void raid_kick(Context ctx, uint id, ulong userID)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID((int)id);

            //Make sure it exists
            Precondition.Assert(handle.HasValue, $"No raid with that id ({id}).");

            //Find the raider that matches the ID
            var player = RaidManager.FindRaider(handle.Value, userID);

            //Check that the raider exists in the roster
            Precondition.Assert(player.HasValue, "That raider is not in the roster.");

            //Pass on to the implementation
            this.raid_kick_impl(ctx, handle.Value, player.Value);
        }
예제 #15
0
        public void raid_leave(Context ctx, uint id)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID((int)id);

            //Make sure it exists
            Precondition.Assert(handle.HasValue, $"No raid with that id ({id}).");

            //Find the raider in the roster
            var player = RaidManager.FindRaider(handle.Value, ctx.message.Author.Id);

            //Check that the raider exists in the roster
            Precondition.Assert(player.HasValue, "You are not in the roster.");

            //Pass on to the implementation
            this.raid_leave_impl(ctx, handle.Value, player.Value);
        }
        private void raid_roster_impl(Context ctx, int id, string roles)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID(id).Value;

            //Extract the roles to create our filter
            var filter = this.raidConfig.MatchRoles(roles);

            //Get the raiders that match the filter
            var roster = RaidManager.CoalesceRaiders(handle)
                         .Where(e => e.roles.Intersect(filter).Count() > 0)
                         .ToList();

            //Check that it's not empty
            if (roster.Count > 0)
            {
                //Resolve their names and roles
                var tmp = roster.Select(e =>
                {
                    //Get the name
                    var name = (e.user_id.HasValue) ? Bot.GetBotInstance().GetUserName(e.user_id.Value)
                                                    : e.user_name;

                    //Check if this entry is a backup
                    if (e.backup)
                    {
                        //Add the roles and cursive style
                        return($"*{name} - {string.Join(", ", e.roles)}*");
                    }

                    //Add the roles
                    return($"{name} - {string.Join(", ", e.roles)}");
                }).ToList();

                //Display the roster
                Bot.GetBotInstance()
                .SendSuccessMessage(ctx.message.Channel, "Result:", string.Join("\n", tmp), $"Count: {tmp.Count}");
            }
            else
            {
                //Empty roster
                Bot.GetBotInstance()
                .SendSuccessMessage(ctx.message.Channel, "Result:", $"None");
            }
        }
예제 #17
0
        public void raid_kick(Context ctx, uint id, [RegexParameter(@"[\S\s]+")] string name)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID((int)id);

            //Make sure it exists
            Precondition.Assert(handle.HasValue, $"No raid with that id ({id}).");

            //Find any raiders that match the name
            var players = RaidManager.FindRaiders(handle.Value, name);

            //Check that we got only one
            Precondition.Assert(players.Count > 0, "No one with that name.");
            Precondition.Assert(players.Count == 1, $"More than one matches that name.");

            //Pass on to the implementation
            this.raid_kick_impl(ctx, handle.Value, players.First());
        }
예제 #18
0
        public override void OnInit()
        {
            //Initialise the raid manager
            RaidManager.Initialise();

            //Load raid config
            this.raidConfig = RaidConfig.ReadConfig();

            //Create a timer to periodically clean up old raids
            Timer t = new Timer(60 * 60 * 1000);

            t.Elapsed += (s, e) =>
            {
                //Delete raids older than 5 hours
                RaidManager.CleanRaidFiles(new TimeSpan(5, 0, 0));
            };
            t.AutoReset = true;
            t.Start();
        }
예제 #19
0
        public void raid_make_comp(Context ctx, [RegexParameter(@"[\S\s]+")] string name, uint id)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID((int)id);

            //Make sure it exists
            Precondition.Assert(handle.HasValue, $"No raid with that id ({id}");

            //Check that the composition exists
            string[] layout;
            Precondition.Assert
            (
                this.raidConfig.Compositions.TryGetValue(name.ToUpper(), out layout),
                "No comp with that name. These are the recognised comps: \n" +
                string.Join(", ", this.raidConfig.Compositions.Keys)
            );

            //Pass on to the implementation
            this.raid_make_comp_impl(ctx, handle.Value, layout);
        }
        private void raid_add_impl(Context ctx, int id, string name, string roles)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID(id).Value;

            //Extract the roles
            var  extractedRoles = this.raidConfig.MatchRoles(roles);
            bool bu             = roles.ToUpper().Contains("BACKUP");

            //Check that we got any roles
            Precondition.Assert(extractedRoles.Length > 0, "No recognized roles provided!");

            //Add to the raid
            RaidManager.AppendRaider(handle, name, bu, extractedRoles);

            //Return success
            Bot.GetBotInstance()
            .SendSuccessMessage(ctx.message.Channel,
                                "Success",
                                $"They were added to the raid{(bu ? " as backup" : "")} with these roles: \"{string.Join(", ", extractedRoles)}\"."
                                );
        }
        private void raid_kick_impl(Context ctx, RaidHandle handle, Entry e)
        {
            //Grab the data from the raid
            var data = RaidManager.GetRaidData(handle);

            //Check that it's valid
            Precondition.Assert(data.HasValue, "There was an error processing the raid.");

            //Get the owner
            var owner_id = data.Value.owner_id;

            //Check that the user is the owner
            Precondition.Assert(ctx.message.Author.Id == owner_id, "You are not the owner of the raid!");

            //Remove from the raid
            RaidManager.RemoveRaider(handle, e);

            //Return success
            Bot.GetBotInstance()
            .SendSuccessMessage(ctx.message.Channel,
                                "Success",
                                $"They were removed from the roster."
                                );
        }
예제 #22
0
    public PartyActivityRecord(PartyActionType actionType, RaidManager raidManager)
    {
        PartyActionType = actionType;
        QuestType       = raidManager.Quest.Type;
        QuestDifficulty = raidManager.Quest.Difficulty.ToString();
        QuestLength     = raidManager.Quest.Length.ToString();
        Dungeon         = raidManager.Quest.Dungeon;
        IsSuccessfull   = raidManager.Status == RaidStatus.Success;

        Names   = new List <string>(raidManager.RaidParty.HeroInfo.Select(item => item.Hero.HeroName));
        Classes = new List <string>(raidManager.RaidParty.HeroInfo.Select(item => item.Hero.Class));
        if (actionType == PartyActionType.Result)
        {
            Alive = new List <bool>(raidManager.RaidParty.HeroInfo.Select(item => item.IsAlive));
        }
        else
        {
            Alive = new List <bool>();
            for (int i = 0; i < Names.Count; i++)
            {
                Alive.Add(true);
            }
        }
    }
        private void raid_delete_impl(Context ctx, int id)
        {
            //Get a handle to the raid
            var handle = RaidManager.GetRaidFromID(id).Value;

            //Grab the data from the raid
            var data = RaidManager.GetRaidData(handle);

            //Check that it's valid
            Precondition.Assert(data.HasValue, "There was an error processing the raid.");

            //Get the owner
            var owner_id = data.Value.owner_id;

            //Check that the user is the owner
            Precondition.Assert(ctx.message.Author.Id == owner_id, "You are not the owner of the raid!");

            //Delete the raid
            RaidManager.DeleteRaid(handle);

            //Return success
            Bot.GetBotInstance()
            .SendSuccessMessage(ctx.message.Channel, "Success", $"Raid has been deleted.");
        }
예제 #24
0
    // Start is called before the first frame update
    void Start()
    {
        if (!dropEventManager)
        {
            dropEventManager = GetComponent <DropEventManager>();
        }
        if (!ferryProgress)
        {
            ferryProgress = FindObjectOfType <FerryProgress>();
        }
        if (!gameCamera)
        {
            gameCamera = FindObjectOfType <GameCamera>();
        }

        if (!playerLogoManager)
        {
            playerLogoManager = GetComponent <PlayerLogoManager>();
        }
        if (!villageManager)
        {
            villageManager = FindObjectOfType <VillageManager>();
        }

        if (!settings)
        {
            settings = GetComponent <GameSettings>();
        }
        if (!subEventManager)
        {
            subEventManager = GetComponent <TwitchEventManager>();
        }
        if (!subEventManager)
        {
            subEventManager = gameObject.AddComponent <TwitchEventManager>();
        }

        if (!commandServer)
        {
            commandServer = GetComponent <CommandServer>();
        }
        if (!islandManager)
        {
            islandManager = GetComponent <IslandManager>();
        }
        if (!itemManager)
        {
            itemManager = GetComponent <ItemManager>();
        }
        if (!playerManager)
        {
            playerManager = GetComponent <PlayerManager>();
        }
        if (!chunkManager)
        {
            chunkManager = GetComponent <ChunkManager>();
        }
        if (!craftingManager)
        {
            craftingManager = GetComponent <CraftingManager>();
        }
        if (!raidManager)
        {
            raidManager = GetComponent <RaidManager>();
        }
        if (!streamRaidManager)
        {
            streamRaidManager = GetComponent <StreamRaidManager>();
        }
        if (!arenaController)
        {
            arenaController = FindObjectOfType <ArenaController>();
        }

        if (!ferryController)
        {
            ferryController = FindObjectOfType <FerryController>();
        }
        if (!musicManager)
        {
            musicManager = GetComponent <MusicManager>();
        }

        RegisterGameEventHandler <ItemAddEventHandler>(GameEventType.ItemAdd);
        RegisterGameEventHandler <ResourceUpdateEventHandler>(GameEventType.ResourceUpdate);
        RegisterGameEventHandler <ServerMessageEventHandler>(GameEventType.ServerMessage);

        RegisterGameEventHandler <VillageInfoEventHandler>(GameEventType.VillageInfo);
        RegisterGameEventHandler <VillageLevelUpEventHandler>(GameEventType.VillageLevelUp);

        RegisterGameEventHandler <PlayerRemoveEventHandler>(GameEventType.PlayerRemove);
        RegisterGameEventHandler <PlayerAddEventHandler>(GameEventType.PlayerAdd);
        RegisterGameEventHandler <PlayerExpUpdateEventHandler>(GameEventType.PlayerExpUpdate);
        RegisterGameEventHandler <PlayerJoinArenaEventHandler>(GameEventType.PlayerJoinArena);
        RegisterGameEventHandler <PlayerJoinDungeonEventHandler>(GameEventType.PlayerJoinDungeon);
        RegisterGameEventHandler <PlayerJoinRaidEventHandler>(GameEventType.PlayerJoinRaid);
        RegisterGameEventHandler <PlayerNameUpdateEventHandler>(GameEventType.PlayerNameUpdate);
        RegisterGameEventHandler <PlayerTaskEventHandler>(GameEventType.PlayerTask);


        RegisterGameEventHandler <StreamerWarRaidEventHandler>(GameEventType.WarRaid);
        RegisterGameEventHandler <StreamerRaidEventHandler>(GameEventType.Raid);
        RegisterGameEventHandler <PlayerAppearanceEventHandler>(GameEventType.PlayerAppearance);
        RegisterGameEventHandler <ItemBuyEventHandler>(GameEventType.ItemBuy);
        RegisterGameEventHandler <ItemSellEventHandler>(GameEventType.ItemSell);

        commandServer.StartServer(this);
        musicManager.PlayBackgroundMusic();
    }
예제 #25
0
    // Start is called before the first frame update
    void Start()
    {
        if (!dropEventManager)
        {
            dropEventManager = GetComponent <DropEventManager>();
        }
        if (!ferryProgress)
        {
            ferryProgress = FindObjectOfType <FerryProgress>();
        }
        if (!gameCamera)
        {
            gameCamera = FindObjectOfType <GameCamera>();
        }

        if (!settings)
        {
            settings = GetComponent <GameSettings>();
        }
        if (!subEventManager)
        {
            subEventManager = GetComponent <TwitchEventManager>();
        }
        if (!subEventManager)
        {
            subEventManager = gameObject.AddComponent <TwitchEventManager>();
        }

        if (!commandServer)
        {
            commandServer = GetComponent <CommandServer>();
        }

        if (!islandManager)
        {
            islandManager = GetComponent <IslandManager>();
        }
        if (!itemManager)
        {
            itemManager = GetComponent <ItemManager>();
        }
        if (!playerManager)
        {
            playerManager = GetComponent <PlayerManager>();
        }
        if (!chunkManager)
        {
            chunkManager = GetComponent <ChunkManager>();
        }
        if (!craftingManager)
        {
            craftingManager = GetComponent <CraftingManager>();
        }
        if (!raidManager)
        {
            raidManager = GetComponent <RaidManager>();
        }
        if (!streamRaidManager)
        {
            streamRaidManager = GetComponent <StreamRaidManager>();
        }
        if (!arenaController)
        {
            arenaController = FindObjectOfType <ArenaController>();
        }

        if (!ferryController)
        {
            ferryController = FindObjectOfType <FerryController>();
        }
        if (!musicManager)
        {
            musicManager = GetComponent <MusicManager>();
        }


        commandServer.StartServer(this);

        musicManager.PlayBackgroundMusic();
    }
        private void raid_make_comp_impl(Context ctx, RaidHandle handle, /*readonly*/ string[] layout)
        {
            //Get the raiders
            var raiders = RaidManager.CoalesceRaiders(handle);

            //Generate composition
            var result = this.GenerateComp(raiders, layout, out Entry[] unused);

            //Setup the embed builder
            var builder = new EmbedBuilder().WithColor(Color.Blue);

            //Get the unique roles in this composition
            var roles = layout.Distinct().ToArray();

            //Go through each role
            foreach (var r in roles)
            {
                //Count the instances of this role in the layout
                var roleCount = layout.Count(str => r == str);

                //Get all players with this assigned role
                var players = result.Where(p => p.assignment == r);

                //Format the names
                var formatted = players.Select(p =>
                {
                    //Get the name of the player
                    var name = (p.player.user_id.HasValue ? Bot.GetBotInstance().GetUserName(p.player.user_id.Value) : p.player.user_name);

                    //Check if backup
                    if (p.player.backup)
                    {
                        //Add cursive
                        return($"*{name}*");
                    }
                    else
                    {
                        return(name);
                    }
                }).ToArray();

                //Check that it's not empty
                if (formatted.Length > 0)
                {
                    //Write the formatted names
                    builder = builder.AddField($"{r} ({formatted.Length}/{roleCount}):", string.Join('\n', formatted));
                }
                else
                {
                    //Add an empty field
                    builder = builder.AddField($"{r} (0/{roleCount}):", "...");
                }
            }

            //Check if we need to add a "not included" category
            if (unused.Length > 0)
            {
                //Format the names
                var formatted = unused.Select(p =>
                {
                    //Get the name of the player
                    var name = (p.user_id.HasValue ? Bot.GetBotInstance().GetUserName(p.user_id.Value) : p.user_name);

                    //Check if backup
                    if (p.backup)
                    {
                        //Add cursive
                        return($"*{name}*");
                    }
                    else
                    {
                        return(name);
                    }
                }).ToArray();

                //Add the field
                builder = builder.AddField("Not included:", string.Join('\n', formatted));
            }

            //Build the embed
            var embed = builder.WithTitle("This is the best comp I could make:")
                        .Build();

            //Send the message
            ctx.message.Channel.SendMessageAsync("", false, embed).GetAwaiter().GetResult();
        }