Beispiel #1
0
        public static async void Initialize()
        {
            Logger = new Logger();
            Logger.Log(
                $"Starting [{DateTime.Now.ToLongTimeString()} - {ServerUtils.GetOSName()}]...",
                null);

            Configuration = new Configuration();
            Configuration.Initialize();

            Fingerprint = new Fingerprint();
            Sentry      = new SentryReport();
            Csv         = new Csv();

            UpdateManager = new UpdateManager();

            PlayerDb   = new PlayerDb();
            AllianceDb = new AllianceDb();

            Logger.Log(
                $"Successfully loaded MySql with {await PlayerDb.CountAsync()} player(s) & {await AllianceDb.CountAsync()} clan(s)",
                null);

            Redis = new Redis();

            Battles   = new Battles();
            Players   = new Players();
            Alliances = new Alliances();

            Leaderboard = new Leaderboard();

            Netty = new NettyService();

            await Task.Run(Netty.RunServerAsync);
        }
Beispiel #2
0
    void Populate(Alliances alliance, List <Unit> team, List <Tile> openTiles)
    {
        for (int i = 0; i < 6; ++i)
        {
            int  rnd  = UnityEngine.Random.Range(0, openTiles.Count);
            Tile tile = openTiles[rnd];
            openTiles.RemoveAt(rnd);

            int  lvl  = UnityEngine.Random.Range(7, 11);
            Unit unit = alliance == Alliances.Hero ? UnitFactory.CreateHero(lvl) : UnitFactory.CreateMonster(lvl);
            unit.alliance = alliance;
            team.Add(unit);

            unit.Place(tile);
            unit.Dir = (Directions)UnityEngine.Random.Range(0, 4);
            unit.Match();

            SkillSet atk = new SkillSet();
            atk.name = "Attack";
            atk.skills.Add(Resources.Load <Ability>("Abilities/_lightAttack"));
            //	atk.skills.Add(Resources.Load<Ability>("Abilities/_mediumAttack"));
            //	atk.skills.Add(Resources.Load<Ability>("Abilities/_heavyAttack"));
            unit.capability.Add(atk);

            SkillSet temp = new SkillSet();
            temp.name = "Black Magic";
            temp.skills.Add(Resources.Load <Ability>("Abilities/Fire"));
            unit.capability.Add(temp);

            turnController.AddUnit(unit);
        }
    }
Beispiel #3
0
        /// <summary>
        /// Tworzy sojusz z wybranym klanem
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonAllianceWith_Click(object sender, EventArgs e)
        {
            List <Tables.Clan> alliedClans = Alliances.GetAll().Where(clan => clan.Clan1Name == CurrentUser.ClanName).Select(clan => clan.Clan2).ToList();

            alliedClans.AddRange(Alliances.GetAll().Where(clan => clan.Clan2Name == CurrentUser.ClanName).Select(clan => clan.Clan1));
            dataGridViewTables.DataSource = alliedClans;
        }
 protected virtual void CheckForGameOver()
 {
     if (PartyDefeated(Alliances.Hero))
     {
         Victor = Alliances.Enemy;
     }
 }
Beispiel #5
0
        internal override void Handle()
        {
            LogicClientAvatar avatar   = this.Connection.Avatar;
            Alliance          alliance = avatar.Alliance;

            if (alliance != null)
            {
                AllianceMember member = alliance.Members.Find(m => m.Identifier == avatar.Identifier);

                avatar.ClanHighID = 0;
                avatar.ClanLowID  = 0;

                avatar.Save();

                if (alliance.Members.Size == 0)
                {
                    Alliances.Delete(alliance);
                }
                else
                {
                    if (member.Role == (int)Alliance.Role.Leader)
                    {
                        LeaveAllianceMessage.FindNewLeader(alliance, member);
                    }
                }

                new AvailableServerCommandMessage(this.Connection, new LogicLeaveAllianceCommand(this.Connection, alliance.Identifier)).Send();
                alliance.AddEntry(new StreamEntry(member, member, StreamEntry.StreamEvent.Left));

                alliance.Members.Remove(member);

                Alliances.Save(alliance);
            }
        }
Beispiel #6
0
        internal override void Handle()
        {
            Alliance alliance = Alliances.Get(this.AllianceID);

            if (alliance != null)
            {
                if (!alliance.Members.Contains(alliance.Members.Find(member => member.Identifier == this.Connection.Avatar.Identifier)))
                {
                    AllianceMember member = new AllianceMember(this.Connection.Avatar, Alliance.Role.Member);
                    alliance.Members.Add(member);

                    this.Connection.Avatar.ClanHighID = alliance.HighID;
                    this.Connection.Avatar.ClanLowID  = alliance.LowID;

                    this.Connection.Avatar.Save();

                    Alliances.Save(alliance);

                    new AvailableServerCommandMessage(this.Connection, new LogicChangeAllianceRoleCommand(this.Connection)
                    {
                        Role = Alliance.Role.Member
                    }).Send();

                    new AvailableServerCommandMessage(this.Connection, new LogicJoinAllianceCommand(this.Connection)).Send();

                    new AllianceStreamMessage(this.Connection).Send();
                    alliance.AddEntry(new StreamEntry(member, member, StreamEntry.StreamEvent.Joined));

                    this.Connection.Avatar.Save();
                }
            }
        }
    public List <Unit> GetAvailableUnits()
    {
        Alliances currentSide = owner.roundController.RoundSide;
        var       roundUnits  = GetUnits(currentSide);

        return(roundUnits.FindAll(u => u.turn.IsAvailable()));
    }
Beispiel #8
0
        public static void Construct()
        {
            Configuration = new Configuration();
            Configuration.Initialize();

            _logger = new Logger();

            Logger.Log($"ENV: {(Utils.IsLinux ? "Linux" : "Windows")}");

            Csv         = new Csv();
            Fingerprint = new Fingerprint();

            _playerDb   = new PlayerDb();
            _replayDb   = new ReplayDb();
            _allianceDb = new AllianceDb();

            _redis = new Redis();

            Levels           = new Levels();
            PlayerCache      = new Players();
            AllianceCache    = new Alliances();
            LeaderboardCache = new Leaderboards();

            ChatManager = new LogicGlobalChatManager();

            Gateway = new Gateway();

            StartDateTime = DateTime.UtcNow;

            Gateway.StartAsync().Wait();
        }
Beispiel #9
0
        internal override void Handle()
        {
            Alliance alliance = Alliances.Get(this.Connection.Avatar.Alliance.Identifier);

            if (alliance != null)
            {
                AllianceMember member = alliance.Members.Find(m => m.Identifier == this.MemberID);
                AllianceMember sender = alliance.Members.Find(m => m.Identifier == this.Connection.Avatar.Identifier);

                alliance.AddEntry(new StreamEntry(member, sender, ChangeAllianceMemberRoleMessage.IsHigherRoleThan(this.Role, member.Role) ? StreamEntry.StreamEvent.Promoted : StreamEntry.StreamEvent.Demoted));
                member.Role = this.Role;

                if (this.Role == (int)Alliance.Role.Leader)
                {
                    sender.Role = (int)Alliance.Role.CoLeader;
                    alliance.AddEntry(new StreamEntry(sender, sender, StreamEntry.StreamEvent.Demoted));
                }

                Alliances.Save(alliance);

                new AvailableServerCommandMessage(this.Connection, new LogicChangeAllianceRoleCommand(this.Connection)
                {
                    Role = (Alliance.Role) this.Role
                }).Send();
            }
        }
    public override bool IsTarget(Tile tile)
    {
        if (tile == null || tile.content == null)
        {
            return(false);
        }
        Alliances me     = GetComponentInParent <Alliance>().type;
        Alliances target = tile.content.GetComponent <Alliance>().type;

        switch (me)
        {
        case Alliances.Enemy:
            return(target != Alliances.Enemy);

        case Alliances.Hero:
            return(target != Alliances.Hero);

        case Alliances.Neutral:
            return(false);

        case Alliances.None:
        default:
            return(true);
        }
    }
        public PageShowAlliances()
        {
            this.AllAlliances = Alliances.GetAlliances();

            InitializeComponent();

            this.Loaded += PageShowAlliances_Loaded;
        }
Beispiel #12
0
 public Turn(int gridSize)
 {
     AllianceProposals = new HashSet<AllianceProposal>();
     Alliances = new Alliances();
     Cells = InitializeCells(gridSize);
     ResetNewUnits();
     TurnNumber = 0;
 }
        internal override void Handle()
        {
            Alliance alliance = Alliances.Get(this.AllianceId);

            if (alliance != null)
            {
                new AllianceDataMessage(this.Connection, alliance).Send();
            }
        }
Beispiel #14
0
    public static Alliances GetOpposing(this Alliances a)
    {
        if (a == Alliances.None)
        {
            return(Alliances.None);
        }

        return(a == Alliances.Ally ? Alliances.Enemy : Alliances.Ally);
    }
    protected virtual void CheckForGameOver(object sender, object args)
    {
        Unit deadUnit = args as Unit;

        if (!PartyAlive(deadUnit.alliance))
        {
            Winner = deadUnit.alliance.GetOpposing();
            print($"Winner: {Winner.ToString()}");
        }
    }
        internal override void Encode()
        {
            var allianceList = Alliances.OrderByDescending();

            this.Stream.WriteInt(allianceList.Count);

            foreach (Alliance alliance in allianceList)
            {
                alliance.EncodeRankingEntry(this.Stream);
            }
        }
    public override bool IsTarget(Tile tile)
    {
        if (tile == null || tile.content == null)
        {
            return(false);
        }

        Alliances other = tile.content.GetComponentInChildren <Unit>().alliance;

        return(other == alliance.GetOpposing());
    }
Beispiel #18
0
        public PageAlliances()
        {
            this.HumanAlliances = GameObject.GetInstance().HumanAirline.Alliances;

            var alliances = Alliances.GetAlliances().OrderBy(a => a.Members.Sum(m => m.Airline.Statistics.getStatisticsValue(GameObject.GetInstance().GameTime.Year - 1, StatisticsTypes.GetStatisticsType("Passengers")))).ToList();

            this.LargestAlliances = alliances.Take(Math.Min(5, alliances.Count)).ToList();
            this.Loaded          += PageAlliances_Loaded;

            InitializeComponent();
        }
        public override LuaTable GetLuaTable(Mission mission)
        {
            var missionAlliances = mission.Alliances.Distinct().ToList();
            var map = new Dictionary <object, object>
            {
                { "alliances", LuaTable.CreateArray(Alliances.Select(a => missionAlliances.IndexOf(a))) },
                { "groups", LuaTable.CreateSet(groups) },
            };

            return(new LuaTable(map));
        }
        public override void updatePage()
        {
            panelSideMenu.Content = null;

            lbAlliances.Items.Refresh();

            lbRequests.Items.Clear();
            foreach (PendingAllianceMember member in from a in Alliances.GetAlliances() where a.PendingMembers.ToList().Find(p => p.Airline == GameObject.GetInstance().HumanAirline) != null select a.PendingMembers.ToList().Find(p => p.Airline == GameObject.GetInstance().HumanAirline))
            {
                lbRequests.Items.Add(member);
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2603"), string.Format(Translator.GetInstance().GetString("MessageBox", "2603", "message"), this.Alliance.Name), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                this.Alliance.removeMember(GameObject.GetInstance().HumanAirline);
                Alliances.RemoveAlliance(this.Alliance);
            }

            this.ParentPage.updatePage();
        }
    protected virtual bool PartyDefeated(Alliances type)
    {
        for (int i = 0; i < bc.units.Count; i++) {
            Alliance a = bc.units[i].GetComponent<Alliance>();
            if(a == null)
                continue;

            if(a.type == type && !IsDefeated(bc.units[i]))
                return false;
        }
        return true;
    }
Beispiel #23
0
        public void Serialize(IGenericWriter writer)
        {
            writer.Write(0); // Version

            writer.Write(Name);
            writer.Write(m_Leader);

            writer.WriteGuildList(m_Members, true);
            writer.WriteGuildList(m_PendingMembers, true);

            Alliances.TryAdd(Name.ToLower(), this);
        }
Beispiel #24
0
        public AllianceInfo(Guild leader, string name, Guild partner)
        {
            m_Leader = leader;
            Name     = name;

            m_Members        = new List <Guild>();
            m_PendingMembers = new List <Guild>();

            leader.Alliance  = this;
            partner.Alliance = this;

            Alliances.TryAdd(Name.ToLower(), this);
        }
Beispiel #25
0
        public void AddAlliance(Alliance alliance, bool sendMessage = true)
        {
            if (alliance.FactionOwner == Faction.OfPlayer)
            {
                alliance.PlayerOwner = true;
            }

            Alliances.Add(alliance);

            if (sendMessage)
            {
                Find.LetterStack.ReceiveLetter("GlobalFactionManager_NewAllianceTitle".Translate(), "GlobalFactionManager_NewAllianceDesc".Translate(alliance.FactionOwner.Name, alliance.AllianceGoalDef.LabelCap), LetterDefOf.NeutralEvent);
            }
        }
 void OnTurnCompleted(object sender, EventArgs e)
 {
     for (int i = 0; i < conditions.Count; ++i)
     {
         victor = conditions[i].Check();
         if (victor != Alliances.Neutral)
         {
             if (victoryEvent != null)
                 victoryEvent(this, EventArgs.Empty);
             Debug.Log("Battle concluded with victor: " + victor.ToString());
             break;
         }
     }
 }
Beispiel #27
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            WPFMessageBoxResult result = WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2604"), Translator.GetInstance().GetString("MessageBox", "2604", "message"), WPFMessageBoxButtons.YesNo);

            if (result == WPFMessageBoxResult.Yes)
            {
                Alliance alliance = new Alliance(GameObject.GetInstance().GameTime, (Alliance.AllianceType)cbType.SelectedItem, txtAllianceName.Text.Trim(), (Airport)cbHeadquarter.SelectedItem);
                alliance.addMember(new AllianceMember(GameObject.GetInstance().HumanAirline, GameObject.GetInstance().GameTime));

                Alliances.AddAlliance(alliance);

                PageNavigator.NavigateTo(new PageAlliances());
            }
        }
Beispiel #28
0
        public void Serialize(IGenericWriter writer)
        {
            writer.Write(0); // Version

            writer.Write(Name);
            writer.Write(m_Leader);

            writer.WriteGuildList(m_Members, true);
            writer.WriteGuildList(m_PendingMembers, true);

            if (!Alliances.ContainsKey(Name.ToLower()))
            {
                Alliances.Add(Name.ToLower(), this);
            }
        }
Beispiel #29
0
 void OnTurnCompleted(object sender, EventArgs e)
 {
     for (int i = 0; i < conditions.Count; ++i)
     {
         victor = conditions[i].Check();
         if (victor != Alliances.Neutral)
         {
             if (victoryEvent != null)
             {
                 victoryEvent(this, EventArgs.Empty);
             }
             Debug.Log("Battle concluded with victor: " + victor.ToString());
             break;
         }
     }
 }
Beispiel #30
0
 protected virtual bool PartyDefeated(Alliances type)
 {
     for (int i = 0; i < bc.units.Count; ++i)
     {
         Alliance a = bc.units[i].GetComponent <Alliance>();
         if (a == null)
         {
             continue;
         }
         if (a.type == type && !IsDefeated(bc.units[i]))
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #31
0
        public AllianceInfo(Guild leader, string name, Guild partner)
        {
            m_Leader = leader;
            Name     = name;

            m_Members        = new List <Guild>();
            m_PendingMembers = new List <Guild>();

            leader.Alliance  = this;
            partner.Alliance = this;

            if (!Alliances.ContainsKey(Name.ToLower()))
            {
                Alliances.Add(Name.ToLower(), this);
            }
        }
        public PageShowAlliances()
        {
            this.AllAlliances = Alliances.GetAlliances();

            this.AllCodesharings = new ObservableCollection <CodeshareAgreementMVVM>();

            var codesharings = Airlines.GetAllAirlines().SelectMany(a => a.Codeshares).Distinct();

            foreach (CodeshareAgreement agreement in codesharings)
            {
                this.AllCodesharings.Add(new CodeshareAgreementMVVM(agreement));
            }

            InitializeComponent();

            this.Loaded += PageShowAlliances_Loaded;
        }
    private void StartRound(Alliances side)
    {
        foreach (var unit in currentUnits)
        {
            unit.Paint(Color.white);
        }

        RoundSide = side;
        this.PostNotification(RoundStartedNotification, side);
        print($"Starting round for side {side}");

        currentUnits = owner.partyController.GetUnits(RoundSide).FindAll(u => u.isAlive);
        foreach (var unit in currentUnits)
        {
            unit.turn.StartTurn();
        }
    }
    void Populate(Alliances alliance, List<Unit> team, List<Tile> openTiles)
    {
        for (int i = 0; i < 6; ++i)
        {
            int rnd = UnityEngine.Random.Range(0, openTiles.Count);
            Tile tile = openTiles[rnd];
            openTiles.RemoveAt(rnd);

            int lvl = UnityEngine.Random.Range(7, 11);
            Unit unit = alliance == Alliances.Hero ? UnitFactory.CreateHero(lvl) : UnitFactory.CreateMonster(lvl);
            unit.alliance = alliance;
            team.Add(unit);

            unit.Place(tile);
            unit.Dir = (Directions)UnityEngine.Random.Range(0, 4);
            unit.Match();

            SkillSet atk = new SkillSet();
            atk.name = "Attack";
            atk.skills.Add(Resources.Load<Ability>("Abilities/_lightAttack"));
        //	atk.skills.Add(Resources.Load<Ability>("Abilities/_mediumAttack"));
        //	atk.skills.Add(Resources.Load<Ability>("Abilities/_heavyAttack"));
            unit.capability.Add(atk);

            SkillSet temp = new SkillSet();
            temp.name = "Black Magic";
            temp.skills.Add(Resources.Load<Ability>("Abilities/Fire"));
            unit.capability.Add(temp);

            turnController.AddUnit(unit);
        }
    }
 protected virtual void CheckForGameOver()
 {
     if (PartyDefeated (Alliances.Hero))
         Victor = Alliances.Enemy;
 }