示例#1
0
        private void FillBattle(Ruler ruler, ItemsTable table, string tableTitle, Chronos.Battle.BattleType type)
        {
            table.Title         = tableTitle;
            table.TitleCssClass = "planetInfoZoneTitle";
            table.TableCssClass = "planetFrame";

            CreateTitle(table);

            if (ruler == null)
            {
                NoBattle(table, 6);
                return;
            }

            ICollection collection = ruler.GetAllBattles(type);

            if (collection.Count == 0)
            {
                NoBattle(table, 6);
                return;
            }

            IEnumerator iter = collection.GetEnumerator( );

            while (iter.MoveNext( ))
            {
                ItemsTableLine line = new ItemsTableLine();

                SimpleBattleInfo bInfo = (SimpleBattleInfo)iter.Current;

                ItemsTableText id    = new ItemsTableText(bInfo.BattleId.ToString(), "resource");
                ItemsTableText enemy = new ItemsTableText(OrionGlobals.getLink(bInfo.Enemy), "resource");

                ItemsTableLink link = new ItemsTableLink(
                    info.getContent("battleAdminUser_viewBattle"),
                    OrionGlobals.calculatePath(string.Format("battle.aspx?id={0}&rulerid={1}", bInfo.BattleId, ruler.Id)),
                    "resource"
                    );

                ItemsTableLinkButton linkButton1 = new ItemsTableLinkButton(bInfo.Owner.Name);
                linkButton1.Click += new EventHandler(linkButton1_Click);

                ItemsTableLinkButton linkButton2 = new ItemsTableLinkButton(bInfo.Enemy.Name);
                linkButton2.Click += new EventHandler(linkButton2_Click);

                ItemsTableImageButton remove = new ItemsTableImageButton(OrionGlobals.getCommonImagePath("remove.gif"), "battle_" + bInfo.BattleId);
                remove.Click += new ImageClickEventHandler(remove_Click);

                line.add(id);
                line.add(enemy);
                line.add(link);
                line.add(linkButton1);
                line.add(linkButton2);
                line.add(remove);

                table.addLine(line);
            }

            this.Controls.Add(table);
        }
示例#2
0
        private void FillBattle( Ruler ruler, ItemsTable table, string tableTitle, Chronos.Battle.BattleType type )
        {
            table.Title = tableTitle;
            table.TitleCssClass = "planetInfoZoneTitle";
            table.TableCssClass = "planetFrame";

            CreateTitle(table);

            if( ruler == null ) {
                NoBattle( table, 6 );
                return;
            }

            ICollection collection = ruler.GetAllBattles( type );

            if( collection.Count == 0 ) {
                NoBattle( table, 6 );
                return;
            }

            IEnumerator iter = collection.GetEnumerator( );

            while( iter.MoveNext( ) ) {
                ItemsTableLine line = new ItemsTableLine();

                SimpleBattleInfo bInfo = (SimpleBattleInfo)iter.Current;

                ItemsTableText id = new ItemsTableText( bInfo.BattleId.ToString(), "resource" );
                ItemsTableText enemy = new ItemsTableText( OrionGlobals.getLink( bInfo.Enemy ), "resource" );

                ItemsTableLink link = new ItemsTableLink(
                        info.getContent( "battleAdminUser_viewBattle" ),
                        OrionGlobals.calculatePath( string.Format("battle.aspx?id={0}&rulerid={1}",bInfo.BattleId,ruler.Id) ),
                        "resource"
                );

                ItemsTableLinkButton linkButton1 = new ItemsTableLinkButton( bInfo.Owner.Name );
                linkButton1.Click += new EventHandler(linkButton1_Click);

                ItemsTableLinkButton linkButton2 = new ItemsTableLinkButton( bInfo.Enemy.Name );
                linkButton2.Click += new EventHandler(linkButton2_Click);

                ItemsTableImageButton remove = new ItemsTableImageButton( OrionGlobals.getCommonImagePath( "remove.gif" ), "battle_" + bInfo.BattleId );
                remove.Click += new ImageClickEventHandler(remove_Click);

                line.add( id );
                line.add( enemy );
                line.add( link );
                line.add( linkButton1 );
                line.add( linkButton2 );
                line.add( remove );

                table.addLine( line );
            }

            this.Controls.Add( table );
        }
示例#3
0
        private bool CanCreateBattle(Ruler r)
        {
            if (r.InVacation)
            {
                return(false);
            }

            if (r.Premium)
            {
                return(true);
            }

            int battleCount = r.GetAllBattles(BattleType.FRIENDLY).Count;
            int battleLimit = int.Parse(OrionGlobals.getConfigurationValue("alnitak", "friendlyLimit"));

            return(battleCount < battleLimit);
        }
示例#4
0
        private void CreateUnits()
        {
            itemsTable.Title         = info.getContent("cancelBattle_acceptReject");
            itemsTable.TitleCssClass = "planetInfoZoneTitle";
            itemsTable.TableCssClass = "planetFrame";

            createTitle(itemsTable);

            ICollection battles = _ruler.GetAllBattles(BattleType.FRIENDLY);

            foreach (SimpleBattleInfo battleInfo in battles)
            {
                if (battleInfo.Accepted)
                {
                    continue;
                }

                ItemsTableLine line = new ItemsTableLine();

                ItemsTableText id    = new ItemsTableText(battleInfo.BattleId.ToString(), "resource");
                ItemsTableText ruler = new ItemsTableText(OrionGlobals.getLink(battleInfo.Enemy), "resource");

                ItemsTableLink view = new ItemsTableLink(
                    info.getContent("currentBattle_viewBattle"),
                    OrionGlobals.calculatePath("battle.aspx?id=" + battleInfo.BattleId),
                    "resource"
                    );

                ItemsTableImageButton accept = new ItemsTableImageButton(OrionGlobals.getCommonImagePath("ok.gif"), "accept_" + battleInfo.BattleId);
                accept.Click += new ImageClickEventHandler(Accept_Click);

                ItemsTableImageButton reject = new ItemsTableImageButton(OrionGlobals.getCommonImagePath("remove.gif"), "reject_" + battleInfo.BattleId);
                reject.Click += new ImageClickEventHandler(Reject_Click);

                line.add(id);
                line.add(ruler);
                line.add(view);
                line.add(accept);
                line.add(reject);

                itemsTable.addLine(line);
            }
        }
示例#5
0
        private bool CanCreateBattle(Ruler r)
        {
            if( r.InVacation ) {
                return false;
            }

            if( r.Premium ) {
                return true;
            }

            int battleCount = r.GetAllBattles(BattleType.FRIENDLY).Count;
            int battleLimit = int.Parse(OrionGlobals.getConfigurationValue("alnitak","friendlyLimit"));

            return battleCount < battleLimit;
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        private ItemsTable CreateBattles()
        {
            ICollection battles = ruler.GetAllBattles(type);

            ItemsTable _itemsTable = new ItemsTable();

            if (TitleRef == null)
            {
                _itemsTable.Title = info.getContent("currentBattle_title");
            }
            else
            {
                _itemsTable.Title = info.getContent(TitleRef);
            }

            _itemsTable.TitleCssClass = "planetInfoZoneTitle";
            _itemsTable.TableCssClass = "planetFrame";

            createTitle(_itemsTable);

            if (battles != null && battles.Count > 0)
            {
                string onlineImage  = OrionGlobals.getCommonImagePath("online.gif");
                string offlineImage = OrionGlobals.getCommonImagePath("offline.gif");

                IEnumerator iter = battles.GetEnumerator( );
                while (iter.MoveNext())
                {
                    SimpleBattleInfo battleInfo = iter.Current as SimpleBattleInfo;

                    if (null == battleInfo)
                    {
                        continue;
                    }

                    if (!battleInfo.Accepted)
                    {
                        continue;
                    }

                    ItemsTableLine line = new ItemsTableLine();

                    ItemsTableText turn = new ItemsTableText(battleInfo.CurrentTurn.ToString(  ), "resource");

                    ItemsTableText opponent = new ItemsTableText(OrionGlobals.getLink(battleInfo.Enemy), "resource");

                    string onlineState;

                    // indicar se o utilizador está online
                    if (OrionGlobals.isUserOnline(battleInfo.Enemy.ForeignId))
                    {
                        onlineState = string.Format("<img src='{0}' />", onlineImage);
                    }
                    else
                    {
                        onlineState = string.Format("<img src='{0}' />", offlineImage);
                    }

                    ItemsTableText opponentStatus = new ItemsTableText(onlineState, "resource");

                    ItemsTableText battleType = new ItemsTableText(info.getContent(battleInfo.Type), "resource");

                    ItemsTableItem status;
                    string         rulerTurn;
                    if (battleInfo.IsPositionTime)
                    {
                        rulerTurn = info.getContent("currentBattle_rulerPosition");
                    }
                    else
                    {
                        if (battleInfo.IsTurn)
                        {
                            if (battleInfo.EnemyIsPositionTime)
                            {
                                rulerTurn = info.getContent("currentBattle_enemyPositioning");
                            }
                            else
                            {
                                rulerTurn = info.getContent("currentBattle_rulerTurn");
                            }
                        }
                        else
                        {
                            rulerTurn = info.getContent("currentBattle_enemyTurn");
                        }
                    }

                    status = new ItemsTableLink(
                        rulerTurn,
                        OrionGlobals.calculatePath("battle.aspx?id=" + battleInfo.BattleId),
                        "resource"
                        );

                    ItemsTableText timeLeft = new ItemsTableText(modifyTime(battleInfo.TurnsLeft.ToString()), "resource");

                    ItemsTableText coordPlanet = null;
                    if (type == Chronos.Battle.BattleType.BATTLE)
                    {
                        if (battleInfo.IsPlanet)
                        {
                            Planet p = Universe.instance.getPlanet(battleInfo.Coordinate);
                            coordPlanet = new ItemsTableText(getPlanetLink(p), "resource");
                        }
                        else
                        {
                            coordPlanet = new ItemsTableText(battleInfo.Coordinate.ToString(), "resource");
                        }
                    }

                    ItemsTableText timeout = new ItemsTableText(battleInfo.MissedTurns.ToString(), "resource");

                    line.add(turn);
                    line.add(opponent);
                    line.add(opponentStatus);
                    line.add(battleType);
                    line.add(status);
                    line.add(timeout);

                    if (type == Chronos.Battle.BattleType.BATTLE)
                    {
                        line.add(coordPlanet);
                    }

                    line.add(timeLeft);
                    _itemsTable.addLine(line);
                }
            }


            if (!_itemsTable.HasControls())
            {
                ItemsTableLine line = new ItemsTableLine();
                ItemsTableText txt  = new ItemsTableText(info.getContent("currentBattle_noBattles"), "resource");

                if (type == Chronos.Battle.BattleType.BATTLE)
                {
                    txt.ColumnSpan = 8;
                }
                else
                {
                    txt.ColumnSpan = 7;
                }

                line.add(txt);
                _itemsTable.addLine(line);
            }

            return(_itemsTable);
        }