コード例 #1
0
 public void StartWar(ConquestGame type)
 {
     WarIsOn = true;
     Envir.Broadcast(new S.Chat {
         Message = string.Format("{0} War has started!", Info.Name), Type = ChatType.System
     });
 }
コード例 #2
0
ファイル: LMS_BR_Info.cs プロジェクト: coolzoom/mir2-master
        public void End_Match(bool foundWinner = false)
        {
            bool   failed      = false;
            string matchResult = "";

            if (foundWinner)
            {
                LMS_Rank     lmsRank       = null;
                PlayerObject winningPlayer = null;
                for (int i = 0; i < CurrentMap.Players.Count; i++)
                {
                    PlayerObject player = CurrentMap.Players[i];
                    if (player == null ||
                        player.Dead)
                    {
                        continue;
                    }
                    for (int x = 0; x < PlayerRanks.Count; x++)
                    {
                        if (player.Name == PlayerRanks[x].Player.Name &&
                            winningPlayer == null &&
                            lmsRank == null)
                        {
                            winningPlayer = player;
                            lmsRank       = PlayerRanks[x];
                        }
                    }
                }
                if (winningPlayer != null &&
                    lmsRank != null)
                {
                    //  TODO Reward players (send by mail)
                    matchResult = string.Format("{0} is the Victor of the match!", winningPlayer.Name);

                    winningPlayer.Teleport(Envir.GetMap(winningPlayer.BindMapIndex), winningPlayer.BindLocation, true, 0);
                    winningPlayer.InLMSBR = false;
                    List <LMS_RewardInfo> rewards = CreateRewards(1, winningPlayer);
                    if (rewards != null &&
                        rewards.Count > 0)
                    {
                        winningPlayer.ReceiveChat(string.Format("Victory is yours! Prize(s) will be sent via mail!"), ChatType.Hint);
                        List <UserItem> items = new List <UserItem>();
                        for (int i = 0; i < rewards.Count; i++)
                        {
                            if (rewards[i].ItemReward == null)
                            {
                                SMain.EnqueueDebugging(string.Format("Null reward"));
                                continue;
                            }
                            ItemInfo iInfo = Envir.GetItemInfo(rewards[i].ItemReward.Index);
                            if (iInfo == null)
                            {
                                SMain.EnqueueDebugging(string.Format("Null item info"));
                                continue;
                            }
                            UserItem item = Envir.CreateFreshItem(iInfo);
                            if (item != null)
                            {
                                items.Add(item);
                            }
                        }
                        MailInfo mail = new MailInfo(winningPlayer.Info.Index)
                        {
                            Items   = items,
                            Message = string.Format("Congratulations on winning the match! here is your prize(s)"),
                            Sender  = string.Format("LMS"),
                            MailID  = ++Envir.NextMailID
                        };
                        mail.Send();
                    }
                    SMain.EnqueueDebugging(string.Format("[LMS BR] Map {0} {1} wins the Match, made {2} kills.", CurrentMap.Info.Title, winningPlayer.Name, lmsRank.Kills));
                }
                else
                {
                    failed = true;
                }
            }
            if ((failed && foundWinner) || !foundWinner)
            {
                if (CurrentMap.Players.Count > 0)
                {
                    string[] finalPlayers = new string[CurrentMap.Players.Count];
                    if (finalPlayers.Length >= 1)
                    {
                        int index = 0;
                        for (int i = 0; i < CurrentMap.Players.Count; i++)
                        {
                            PlayerObject player = CurrentMap.Players[i];
                            if (player.Dead ||
                                player.IsGM)
                            {
                                continue;
                            }
                            finalPlayers[index] = player.Name;
                            player.Teleport(Envir.GetMap(player.BindMapIndex), player.BindLocation);
                            player.InLMSBR = failed;
                            index++;
                        }
                        Array.Resize(ref finalPlayers, index);
                    }
                    matchResult = "Stalemate, Players ";
                    for (int i = 0; i < finalPlayers.Length; i++)
                    {
                        matchResult += string.Format("{0}{1} ", finalPlayers[i], i - 1 <= finalPlayers.Length ? "," : " have drawn the match!");
                    }
                }
            }

            if (matchResult.Length > 0)
            {
                Envir.Broadcast(new ServerPackets.Chat {
                    Message = matchResult, Type = ChatType.Announcement
                });
            }
            StartTime        = 0;
            EndTime          = 0;
            SignedupPlayers  = new List <PlayerObject>();
            CircleLocations  = new List <Point>();
            PlayerRanks      = new List <LMS_Rank>();
            StartingLocation = Info.StartingLocation;
            Stage            = 0;
            Finished         = false;
            Started          = false;
        }
コード例 #3
0
        public void TakeConquest(PlayerObject player = null, GuildObject winningGuild = null)
        {
            if (winningGuild == null && (player == null || player.MyGuild == null || player.MyGuild.Conquest != null))
            {
                return;
            }
            if (winningGuild != null && winningGuild.Conquest != null)
            {
                return;
            }
            if (player != null && player.MyGuild != null && player.MyGuild.Conquest != null)
            {
                return;
            }

            GuildObject tmpPrevious = null;

            switch (GameType)
            {
            case ConquestGame.CapturePalace:
                if (player == null)
                {
                    return;
                }
                if (StartType == ConquestType.Request)
                {
                    if (player.MyGuild.Guildindex != AttackerID)
                    {
                        break;
                    }
                }

                if (Guild != null)
                {
                    tmpPrevious    = Guild;
                    Guild.Conquest = null;
                    AttackerID     = tmpPrevious.Guildindex;
                }

                Owner = player.MyGuild.Guildindex;
                Guild = player.MyGuild;
                player.MyGuild.Conquest = this;
                EndWar(GameType);
                break;

            case ConquestGame.KingOfHill:
            case ConquestGame.Classic:
                if (StartType == ConquestType.Request)
                {
                    if (winningGuild.Guildindex != AttackerID)
                    {
                        break;
                    }
                }

                if (Guild != null)
                {
                    tmpPrevious    = Guild;
                    Guild.Conquest = null;
                    AttackerID     = tmpPrevious.Guildindex;
                }

                Owner          = winningGuild.Guildindex;
                Guild          = winningGuild;
                Guild.Conquest = this;
                if (Guild != null && (Guild.Name != "" || Guild.Name != null))
                {
                    Envir.Broadcast(new S.Chat {
                        Message = string.Format("{0} guild are now occupying {1}!", Guild.Name, Info.Name), Type = ChatType.System
                    });
                }
                break;

            case ConquestGame.ControlPoints:
                Owner          = winningGuild.Guildindex;
                Guild          = winningGuild;
                Guild.Conquest = this;

                List <ConquestFlagObject> keys = new List <ConquestFlagObject>(ControlPoints.Keys);
                foreach (ConquestFlagObject key in keys)
                {
                    key.ChangeOwner(Guild);
                    ControlPoints[key] = new Dictionary <GuildObject, int>();
                }

                break;
            }

            for (int i = 0; i < FlagList.Count; i++)
            {
                FlagList[i].Guild = Guild;
                FlagList[i].UpdateImage();
                FlagList[i].UpdateColour();
            }

            UpdatePlayers(Guild);
            if (tmpPrevious != null)
            {
                UpdatePlayers(tmpPrevious);
            }
            NeedSave = true;
        }
コード例 #4
0
        public void AutoSchedule()
        {
            int start  = ((Info.StartHour * 60));
            int finish = ((Info.StartHour * 60) + Info.WarLength);
            int now    = ((DateTime.Now.Hour * 60) + DateTime.Now.Minute);

            if (CheckDay())
            {
                //          Pete        Auto Announce.      12/09/2016
                if (AttackerID != -1)
                {
                    if (now == 1080 && !hasAnnounce)        //  18:00
                    {
                        Envir.Broadcast(new S.Chat {
                            Message = string.Format("{0} war will start in 1 hour!", Info.Name), Type = ChatType.System
                        });
                        hasAnnounce = true;
                    }
                    if (now == 1081)
                    {
                        hasAnnounce = false;
                    }

                    if (now == 1110 && !hasAnnounce)        //  18:30
                    {
                        Envir.Broadcast(new S.Chat {
                            Message = string.Format("{0} war will start in 30 minutes!", Info.Name), Type = ChatType.System
                        });
                        hasAnnounce = true;
                    }
                    if (now == 1111)
                    {
                        hasAnnounce = false;
                    }

                    if (now == 1130 && !hasAnnounce)        //  18:50
                    {
                        Envir.Broadcast(new S.Chat {
                            Message = string.Format("{0} war will start in 10 minutes!", Info.Name), Type = ChatType.System
                        });
                        hasAnnounce = true;
                    }
                    if (now == 1131)
                    {
                        hasAnnounce = false;
                    }

                    if (now == 1160 && !hasAnnounce)        //  19:20
                    {
                        Envir.Broadcast(new S.Chat {
                            Message = string.Format("{0} war will end in 10 minutes!", Info.Name), Type = ChatType.System
                        });
                        hasAnnounce = true;
                    }
                    if (now == 1161)
                    {
                        hasAnnounce = false;
                    }
                }
            }

            if (WarIsOn && StartType == ConquestType.Forced && WarEndTime <= DateTime.Now)
            {
                EndWar(Info.Game);
            }

            if (StartType != ConquestType.Forced)
            {
                if (WarIsOn && now == 1170)
                {
                    EndWar(Info.Game);
                    if (Guild != null && Guild.Name != null &&
                        Guild.Name != "")
                    {
                        if (!hasAnnounce)                        //  21:00
                        {
                            Envir.Broadcast(new S.Chat {
                                Message = string.Format("{0} war has ended! The winning guild {1} now occupy {0}!", Info.Name, Guild.Name), Type = ChatType.System
                            });
                            hasAnnounce = true;
                        }
                    }
                }
                else if (start <= now && finish > now && CheckDay())
                {
                    if (!WarIsOn)
                    {
                        if (Info.Type == ConquestType.Request)
                        {
                            if (AttackerID != -1)
                            {
                                GameType  = Info.Game;
                                StartType = Info.Type;
                                StartWar(Info.Game);
                            }
                        }
                        else
                        {
                            GameType  = Info.Game;
                            StartType = Info.Type;
                            StartWar(Info.Game);
                        }
                    }
                }
            }
            ScheduleTimer = Envir.Time + Settings.Minute;
        }