コード例 #1
0
ファイル: Duel.cs プロジェクト: Zayelion/windbot
 public void AddCard(CardLocation loc, int cardId, int player, int zone, int pos)
 {
     switch (loc)
     {
         case CardLocation.Hand:
             Fields[player].Hand.Add(new ClientCard(cardId, loc, pos));
             break;
         case CardLocation.Grave:
             Fields[player].Graveyard.Add(new ClientCard(cardId, loc, pos));
             break;
         case CardLocation.Removed:
             Fields[player].Banished.Add(new ClientCard(cardId, loc, pos));
             break;
         case CardLocation.MonsterZone:
             Fields[player].MonsterZone[zone] = new ClientCard(cardId, loc, pos);
             break;
         case CardLocation.SpellZone:
             Fields[player].SpellZone[zone] = new ClientCard(cardId, loc, pos);
             break;
         case CardLocation.Deck:
             Fields[player].Deck.Add(new ClientCard(cardId, loc, pos));
             break;
         case CardLocation.Extra:
             Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, pos));
             break;
     }
 }
コード例 #2
0
ファイル: ClientCard.cs プロジェクト: duelqiuqiu/DevBot
 public ClientCard(int id, CardLocation loc, int position)
 {
     SetId(id);
     Position = position;
     ActionIndex = new int[16];
     ActionActivateIndex = new Dictionary<int, int>();
     Location = loc;
 }
コード例 #3
0
 public void SelectThirdCard(CardLocation loc)
 {
     if (m_selector_pointer == -1)
     {
         Log(LogLevel.Error, "Error: Call SelectThirdCard() before SelectCard()");
         m_selector_pointer = 0;
     }
     m_selector.Insert(m_selector_pointer, new CardSelector(loc));
 }
コード例 #4
0
 public ClientCard(int id, CardLocation loc, int position)
 {
     SetId(id);
     Position            = position;
     Overlays            = new List <int>();
     ActionIndex         = new int[16];
     ActionActivateIndex = new Dictionary <int, int>();
     Location            = loc;
 }
コード例 #5
0
 public void SelectThirdCard(CardLocation loc)
 {
     if (this.selector_pointer == -1)
     {
         Logger.WriteErrorLine("Error: Call SelectThirdCard() before SelectCard()");
         this.selector_pointer = 0;
     }
     this.selector.Insert(this.selector_pointer, new CardSelector(loc));
 }
コード例 #6
0
 public void SetLocation(CardLocation location)
 {
     // somewhat unfortunate that these methods have to exist but the card must know where to draw itself
     if (location != CardLocation.Stock)
     {
         throw new ArgumentException("SetLocation must receive at least one int arguments for locations other than the stock.");
     }
     SetLocation(location, 0, 0);
 }
コード例 #7
0
ファイル: GameAI.cs プロジェクト: Wind2009-Louse/windbot
 public void SelectNextCard(CardLocation loc)
 {
     if (m_selector_pointer == -1)
     {
         Logger.WriteErrorLine("Error: Call SelectNextCard() before SelectCard()");
         m_selector_pointer = 0;
     }
     m_selector.Insert(m_selector_pointer, new CardSelector(loc));
 }
コード例 #8
0
ファイル: Klondike.cs プロジェクト: bkgood/misc-code
        /// <summary>
        /// Handles a second click (i.e. the highlight queue is populated) on a special location.
        /// Handles moving card(s) to a foundation or an empty tableau.
        /// </summary>
        /// <param name="point">Location of click</param>
        /// <param name="clickedLocation">Location which was clicked</param>
        void HandleSecondClickOnLocation(Point point, CardLocation clickedLocation)
        {
            switch (clickedLocation)
            {
            case CardLocation.Foundation:
                int foundationNum = GetFoundationNumberAtPoint(point);
                if (IsValidMove(CardLocation.Foundation, foundationNum, highlightedCards))
                {
                    // preform move
                    Card toMove = highlightedCards[0];
                    switch (toMove.Location)
                    {
                    case CardLocation.Waste:
                        waste.Remove(toMove);
                        UpdateScore(CardLocation.Waste, CardLocation.Foundation);
                        break;

                    case CardLocation.Tableau:
                        tableaux[toMove.PileNumber].Remove(toMove);
                        UpdateScore(CardLocation.Tableau, CardLocation.Foundation);
                        break;
                    }
                    toMove.SetLocation(CardLocation.Foundation, foundationNum);
                    foundations[foundationNum].Add(toMove);
                }
                break;

            case CardLocation.Tableau:                     // only works on empty tableaux
                int tableauNum = GetTableauNumberAtPoint(point);
                if (IsValidMove(CardLocation.Tableau, tableauNum, highlightedCards))
                {
                    switch (highlightedCards[0].Location)
                    {
                    case CardLocation.Waste:
                        waste.Remove(highlightedCards[0]);
                        UpdateScore(CardLocation.Waste, CardLocation.Tableau);
                        break;

                    case CardLocation.Tableau:
                        foreach (Card card in highlightedCards)
                        {
                            tableaux[card.PileNumber].Remove(card);
                        }
                        break;
                    }
                    int count = 0;
                    foreach (Card card in highlightedCards)
                    {
                        card.SetLocation(CardLocation.Tableau, tableauNum, count);
                        tableaux[tableauNum].Add(card);
                        count++;
                    }
                }
                break;
            }
        }
        private void OnSelectSum(GameServerPacket packet)
        {
            packet.ReadByte();             // mode
            packet.ReadByte();             // player
            int sumval = packet.ReadInt32();
            int min    = packet.ReadByte();
            int max    = packet.ReadByte();

            IList <ClientCard> cards = new List <ClientCard>();
            int count = packet.ReadByte();

            for (int i = 0; i < count; ++i)
            {
                int          cardId = packet.ReadInt32();
                int          player = GetLocalPlayer(packet.ReadByte());
                CardLocation loc    = (CardLocation)packet.ReadByte();
                int          seq    = packet.ReadByte();
                ClientCard   card   = _duel.GetCard(player, loc, seq);
                if (card != null)
                {
                    if (cardId != 0 && card.Id != cardId)
                    {
                        card.SetId(cardId);
                    }
                    cards.Add(card);
                }
                packet.ReadInt32();
            }

            IList <ClientCard> selected = _ai.OnSelectSum(cards, sumval, min, max);

            byte[] result = new byte[selected.Count + 1];
            result[0] = (byte)selected.Count;
            for (int i = 0; i < selected.Count; ++i)
            {
                int id = 0;
                for (int j = 0; j < count; ++j)
                {
                    if (cards[j] == null)
                    {
                        continue;
                    }
                    if (cards[j].Equals(selected[i]))
                    {
                        id = j;
                        break;
                    }
                }
                result[i + 1] = (byte)id;
            }

            GameClientPacket reply = new GameClientPacket(CtosMessage.Response);

            reply.Write(result);
            Connection.Send(reply);
        }
コード例 #10
0
ファイル: Card.cs プロジェクト: aidan-waite/openware
        public Card(Suit s)
        {
            suit = s;

            CardRank[] cardRanks = (CardRank[])Enum.GetValues(typeof(CardRank));
            int        ind       = UnityEngine.Random.Range(0, cardRanks.Length);

            cardRank     = cardRanks[ind];
            cardLocation = CardLocation.Community;
        }
コード例 #11
0
ファイル: Card.cs プロジェクト: aidan-waite/openware
        public Card(CardRank r)
        {
            cardRank = r;

            Suit[] suits = (Suit[])Enum.GetValues(typeof(Suit));
            int    ind   = UnityEngine.Random.Range(0, suits.Length);

            suit         = suits[ind];
            cardLocation = CardLocation.Community;
        }
        private void OnUpdateData(GameServerPacket packet)
        {
            int          player = GetLocalPlayer(packet.ReadByte());
            CardLocation loc    = (CardLocation)packet.ReadByte();

            IList <ClientCard> cards = null;

            switch (loc)
            {
            case CardLocation.Hand:
                cards = _duel.Fields[player].Hand;
                break;

            case CardLocation.MonsterZone:
                cards = _duel.Fields[player].MonsterZone;
                break;

            case CardLocation.SpellZone:
                cards = _duel.Fields[player].SpellZone;
                break;

            case CardLocation.Grave:
                cards = _duel.Fields[player].Graveyard;
                break;

            case CardLocation.Removed:
                cards = _duel.Fields[player].Banished;
                break;

            case CardLocation.Deck:
                cards = _duel.Fields[player].Deck;
                break;

            case CardLocation.Extra:
                cards = _duel.Fields[player].ExtraDeck;
                break;
            }
            if (cards != null)
            {
                foreach (ClientCard card in cards)
                {
                    try{
                        int len = packet.ReadInt32();
                        if (len < 8)
                        {
                            continue;
                        }
                        long pos = packet.GetPosition();
                        card.Update(packet, _duel);
                        packet.SetPosition(pos + len - 4);
                    }catch (Exception) {
                    }
                }
            }
        }
コード例 #13
0
    public void AddCard(DuelCard duelcard)
    {
        if (duelcard == null)
        {
            return;
        }
        CardLocation cardlocal = new CardLocation();

        cardlocal.SetLocation(duelcard);
        card.Add(cardlocal);
    }
コード例 #14
0
 public gameHiddenButton(CardLocation l, int p)
 {
     ps            = new GPS();
     ps.controller = (UInt32)p;
     ps.location   = (UInt32)l;
     ps.position   = 0;
     ps.sequence   = 0;
     Program.I().ocgcore.AddUpdateAction_s(Update);
     player     = p;
     location   = l;
     gameObject = create(Program.I().mod_ocgcore_hidden_button);
 }
コード例 #15
0
ファイル: SolitaireGame.cs プロジェクト: Primaski/Primbot-v.2
 private bool CheckPowerCardForCards()
 {
     if (powerCard == cardFrom)
     {
         cardFromLoc = CardLocation.POWER_CARD;
     }
     if (powerCard == cardTo)
     {
         cardToLoc = CardLocation.POWER_CARD;
     }
     return(cardFromLoc != CardLocation.NOWHERE && cardToLoc != CardLocation.NOWHERE);
 }
コード例 #16
0
ファイル: GameBehavior.cs プロジェクト: yesicant/windbot
        private void OnUpdateData(BinaryReader packet)
        {
            int          player = GetLocalPlayer(packet.ReadByte());
            CardLocation loc    = (CardLocation)packet.ReadByte();

            IList <ClientCard> cards = null;

            switch (loc)
            {
            case CardLocation.Hand:
                cards = _duel.Fields[player].Hand;
                break;

            case CardLocation.MonsterZone:
                cards = _duel.Fields[player].MonsterZone;
                break;

            case CardLocation.SpellZone:
                cards = _duel.Fields[player].SpellZone;
                break;

            case CardLocation.Grave:
                cards = _duel.Fields[player].Graveyard;
                break;

            case CardLocation.Removed:
                cards = _duel.Fields[player].Banished;
                break;

            case CardLocation.Deck:
                cards = _duel.Fields[player].Deck;
                break;

            case CardLocation.Extra:
                cards = _duel.Fields[player].ExtraDeck;
                break;
            }
            if (cards != null)
            {
                foreach (ClientCard card in cards)
                {
                    int len = packet.ReadInt32();
                    if (len == 4)
                    {
                        continue;
                    }
                    long pos = packet.BaseStream.Position;
                    card.Update(packet, _duel);
                    packet.BaseStream.Position = pos + len - 4;
                }
            }
        }
コード例 #17
0
ファイル: ClientCard.cs プロジェクト: Qianjx/windbot
 public ClientCard(int id, CardLocation loc, int sequence, int position)
 {
     SetId(id);
     Sequence            = sequence;
     Position            = position;
     Overlays            = new List <int>();
     EquipCards          = new List <ClientCard>();
     OwnTargets          = new List <ClientCard>();
     TargetCards         = new List <ClientCard>();
     ActionIndex         = new int[16];
     ActionActivateIndex = new Dictionary <int, int>();
     Location            = loc;
 }
コード例 #18
0
ファイル: ClientCard.cs プロジェクト: IMJoyJ/windbot
 public ClientCard(int id, CardLocation loc, int sequence, int position)
 {
     this.SetId(id);
     this.Sequence            = sequence;
     this.Position            = position;
     this.Overlays            = new List <int>();
     this.EquipCards          = new List <ClientCard>();
     this.OwnTargets          = new List <ClientCard>();
     this.TargetCards         = new List <ClientCard>();
     this.ActionIndex         = new int[16];
     this.ActionActivateIndex = new Dictionary <int, int>();
     this.Location            = loc;
 }
コード例 #19
0
        internal List <ClientCard> GetCards(int player, CardLocation location, bool sortBySeq = false)
        {
            if (location == CardLocation.Hand)
            {
                return(HandCards[player]);
            }
            var list = activeCards.FindAll((c) => c.Location == (int)location && c.Controller == player);

            if (sortBySeq)
            {
                list.Sort(ClientCard.SequenceCompare);
            }
            return(list);
        }
コード例 #20
0
ファイル: Klondike.cs プロジェクト: bkgood/misc-code
        /// <summary>
        /// Checks that moving a set of cards to a certain location is within the rules of our game.
        /// </summary>
        /// <param name="to">Which sort of location we're moving to.</param>
        /// <param name="pileNum">The index of the foundation or tableau we're moving to.</param>
        /// <param name="cards">A list of cards to be moved. MUST BE A PROPER PILE (i.e. alternating colors), THIS METHOD ASSUMES SO.</param>
        /// <returns>True if proper move, false otherwise.</returns>
        bool IsValidMove(CardLocation to, int pileNum, List <Card> cards)
        {
            if (cards.Count == 0)
            {
                return(false);
            }
            switch (to)
            {
            case CardLocation.Foundation:
                List <Card> foundation = foundations[pileNum];
                if (cards.Count != 1)
                {
                    return(false);
                }
                if (foundation.Count == 0 && cards[0].Rank == CardRank.Ace)
                {
                    return(true);
                }
                if (foundation.Count > 0)
                {
                    Card lastCard = foundation.Last();
                    if (lastCard.Suit == cards[0].Suit && lastCard.Rank == (cards[0].Rank - 1))
                    {
                        return(true);
                    }
                }
                return(false);

            case CardLocation.Tableau:
                List <Card> tableau = tableaux[pileNum];
                Card        first   = cards.First();
                Card        last;
                if (tableau.Count == 0 && first.Rank == CardRank.King)
                {
                    return(true);
                }
                else if (tableau.Count == 0 && first.Rank != CardRank.King)
                {
                    return(false);
                }
                last = tableau.Last();
                if (first.Color != last.Color && first.Rank == (last.Rank - 1))
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
コード例 #21
0
ファイル: CardObject.cs プロジェクト: MFHabibie/UnityProjects
    public void OnPointerDown(PointerEventData eventData)
    {
        if (eventData.pointerEnter == this.gameObject)
        {
            isOnClick = true;

            if (locationCollider != null)
            {
                CardLocation cardLoc = locationCollider.GetComponent <CardLocation>();
                cardLoc.isAlreadyFilled = false;
                RemoveOnSet(cardLoc);
                locationCollider = null;
            }
        }
    }
コード例 #22
0
 public override int OnSelectPlace(int cardId, int player, CardLocation location, int available)
 {
     if (cardId == CardID.MathmechFinalSigma)
     {
         if ((Zones.z5 & available) > 0)
         {
             return(Zones.z5);
         }
         if ((Zones.z6 & available) > 0)
         {
             return(Zones.z6);
         }
     }
     return(base.OnSelectPlace(cardId, player, location, available));
 }
コード例 #23
0
 public void SetLocation(CardLocation location, int pileNum, int pileIndex)
 {
     if (pileNum < 0)
     {
         throw new ArgumentException(String.Format("pileNum must be positive or zero, got {0} for card {1}\n", pileNum, this));
     }
     if (pileIndex < 0)
     {
         throw new ArgumentException(String.Format("pileIndex must be positive or zero, got {0} for card {1}\n", pileIndex, this));
     }
     this.location        = location;
     this.pileNum         = pileNum;
     this.pileIndex       = pileIndex;
     this.locationChanged = true;
 }
コード例 #24
0
 public override int OnSelectPlace(int cardId, int player, CardLocation location, int available)
 {
     if (location == CardLocation.MonsterZone)
     {
         if (cardId == CardId.SalamangreatAlmiraj)
         {
             return(available & Zones.ExtraMonsterZones);
         }
         if (cardId == CardId.TGHyperLibrarian && Bot.GetMonsterCount() >= 3)
         {
             return(available & Zones.ExtraMonsterZones);
         }
         return(available & Zones.MainMonsterZones & ~Bot.GetLinkedZones() & ~(Zones.z2 + Zones.z4)); // preserve place for arboria
     }
     return(0);
 }
コード例 #25
0
ファイル: SolitaireGame.cs プロジェクト: Primaski/Primbot-v.2
 private bool CheckFoundationForCards()
 {
     for (int i = 0; i < foundations.Length; i++)
     {
         //IF ORDER IN CARDLOCATION ENUM CHANGES, THEN THIS METHOD NEEDS TO BE TOO
         if (cardFromLoc != CardLocation.NOWHERE && cardFrom == foundations[i])
         {
             cardFromLoc = (CardLocation)(i + 8);
         }
         if (cardToLoc != CardLocation.NOWHERE && cardTo == foundations[i])
         {
             cardToLoc = (CardLocation)(i + 8);
         }
     }
     return(cardFromLoc != CardLocation.NOWHERE && cardToLoc != CardLocation.NOWHERE);
 }
コード例 #26
0
        public ClientCard GetCard(int player, CardLocation loc, int index)
        {
            switch (loc)
            {
            case CardLocation.SpellZone:
                return(Fields[player].SpellZone[index]);

            case CardLocation.MonsterZone:
                return(Fields[player].MonsterZone[index]);

            case CardLocation.Hand:
                if (Fields[player].Hand.Count > index)
                {
                    return(Fields[player].Hand[index]);
                }
                break;

            case CardLocation.Grave:
                if (Fields[player].Graveyard.Count > index)
                {
                    return(Fields[player].Graveyard[index]);
                }
                break;

            case CardLocation.Removed:
                if (Fields[player].Banished.Count > index)
                {
                    return(Fields[player].Banished[index]);
                }
                break;

            case CardLocation.Deck:
                if (Fields[player].Deck.Count > index)
                {
                    return(Fields[player].Deck[index]);
                }
                break;

            case CardLocation.Extra:
                if (Fields[player].ExtraDeck.Count > index)
                {
                    return(Fields[player].ExtraDeck[index]);
                }
                break;
            }
            return(null);
        }
        private void OnSelectBattleCmd(GameServerPacket packet)
        {
            packet.ReadByte();             // player
            _duel.BattlePhase = new BattlePhase();
            BattlePhase battle = _duel.BattlePhase;

            int count = packet.ReadByte();

            for (int i = 0; i < count; ++i)
            {
                packet.ReadInt32();                 // card id
                int          con  = GetLocalPlayer(packet.ReadByte());
                CardLocation loc  = (CardLocation)packet.ReadByte();
                int          seq  = packet.ReadByte();
                int          desc = packet.ReadInt32();

                ClientCard card = _duel.GetCard(con, loc, seq);
                if (card != null)
                {
                    card.ActionIndex[0] = i;
                    battle.ActivableCards.Add(card);
                    battle.ActivableDescs.Add(desc);
                }
            }

            count = packet.ReadByte();
            for (int i = 0; i < count; ++i)
            {
                packet.ReadInt32();                 // card id
                int          con = GetLocalPlayer(packet.ReadByte());
                CardLocation loc = (CardLocation)packet.ReadByte();
                int          seq = packet.ReadByte();
                packet.ReadByte();                 // diratt

                ClientCard card = _duel.GetCard(con, loc, seq);
                if (card != null)
                {
                    card.ActionIndex[1] = i;
                    battle.AttackableCards.Add(_duel.GetCard(con, loc, seq));
                }
            }

            battle.CanMainPhaseTwo = packet.ReadByte() != 0;
            battle.CanEndPhase     = packet.ReadByte() != 0;

            Connection.Send(CtosMessage.Response, _ai.OnSelectBattleCmd(battle).ToValue());
        }
コード例 #28
0
ファイル: CardObject.cs プロジェクト: MFHabibie/UnityProjects
 void RemoveOnSet(CardLocation loc)
 {
     if (loc.setupLine == CardSetup.FirstLine && setupCard.firstLineSet.Count != 0)
     {
         setupCard.firstLineSet.Remove(card);
         setupCard.CheckFirstLine();
     }
     else if (loc.setupLine == CardSetup.SecondLine && setupCard.secondLineSet.Count != 0)
     {
         setupCard.secondLineSet.Remove(card);
         setupCard.CheckSecondLine();
     }
     else if (loc.setupLine == CardSetup.ThirdLine && setupCard.thirdLineSet.Count != 0)
     {
         setupCard.thirdLineSet.Remove(card);
         setupCard.CheckThirdLine();
     }
 }
コード例 #29
0
ファイル: CardObject.cs プロジェクト: MFHabibie/UnityProjects
 void AddToSet(CardLocation loc)
 {
     if (loc.setupLine == CardSetup.FirstLine)
     {
         setupCard.firstLineSet.Add(card);
         setupCard.CheckFirstLine();
     }
     else if (loc.setupLine == CardSetup.SecondLine)
     {
         setupCard.secondLineSet.Add(card);
         setupCard.CheckSecondLine();
     }
     else
     {
         setupCard.thirdLineSet.Add(card);
         setupCard.CheckThirdLine();
     }
 }
コード例 #30
0
ファイル: Klondike.cs プロジェクト: bkgood/misc-code
 /// <summary>
 /// Increments the score based upon where a card was moved to and from.
 /// </summary>
 /// <param name="from">Where the card began.</param>
 /// <param name="to">Where the card was moved.</param>
 void UpdateScore(CardLocation from, CardLocation to)
 {
     //Waste to Tableau	5
     //Waste to Foundation	10
     //Tableau to Foundation	10
     if (from == CardLocation.Waste && to == CardLocation.Tableau)
     {
         score += 5;
     }
     else if (from == CardLocation.Waste && to == CardLocation.Foundation)
     {
         score += 10;
     }
     else if (from == CardLocation.Tableau && to == CardLocation.Foundation)
     {
         score += 10;
     }
 }
コード例 #31
0
        internal void UpdateFieldCard(int player, int location, BinaryReader reader)
        {
            CardLocation      loc  = (CardLocation)location;
            List <ClientCard> list = GetCards(player, loc, true);

            if (loc != CardLocation.MonsterZone && loc != CardLocation.SpellZone)
            {
                foreach (var card in list)
                {
                    int len = reader.ReadInt32();
                    if (len > 8)
                    {
                        long pos = reader.BaseStream.Position;
                        card.UpdateInfo(reader);
                        reader.BaseStream.Position = pos + len - 4;
                    }
                }
            }
            else
            {
                int count = 7;
                for (int i = 0; i < count; ++i)
                {
                    sequencePointer.Add(i, null);
                }
                foreach (var card in list)
                {
                    sequencePointer[card.Sequence] = card;
                }
                for (int i = 0; i < count; ++i)
                {
                    int len = reader.ReadInt32();
                    if (len > 8)
                    {
                        long pos = reader.BaseStream.Position;
                        sequencePointer[i].UpdateInfo(reader);
                        reader.BaseStream.Position = pos + len - 4;
                    }
                }
                sequencePointer.Clear();
            }
        }
コード例 #32
0
        public void Read()
        {
            string[] inputs   = Console.ReadLine().Split(' ');
            int      location = int.Parse(inputs[2]);

            CardNumber = int.Parse(inputs[0]);
            InstanceId = int.Parse(inputs[1]);
            Location   = location == 0 ? CardLocation.MyHand : location == 1 ? CardLocation.MyBoard : CardLocation.OpponentBoard;
            CardType   = (CardType)int.Parse(inputs[3]);
            Cost       = int.Parse(inputs[4]);
            Attack     = int.Parse(inputs[5]);
            Defense    = int.Parse(inputs[6]);
            Abilities  = Bonus.None;
            if (inputs[7][0] == 'B')
            {
                Abilities |= Bonus.Breakthrough;
            }
            if (inputs[7][1] == 'C')
            {
                Abilities |= Bonus.Charge;
            }
            if (inputs[7][2] == 'D')
            {
                Abilities |= Bonus.Drain;
            }
            if (inputs[7][3] == 'G')
            {
                Abilities |= Bonus.Guard;
            }
            if (inputs[7][4] == 'L')
            {
                Abilities |= Bonus.Lethal;
            }
            if (inputs[7][5] == 'W')
            {
                Abilities |= Bonus.Ward;
            }

            MyHealthChange       = int.Parse(inputs[8]);
            OpponentHealthChange = int.Parse(inputs[9]);
            CardDraw             = int.Parse(inputs[10]);
        }
コード例 #33
0
ファイル: GameRoom.cs プロジェクト: 247321453/YgoServer
        private void InitSpectatorLocation(GameSession player, CardLocation loc)
        {
            for (int index = 0; index < 2; index++)
            {
                int flag = loc == CardLocation.MonsterZone ? 0x91fff : 0x81fff;
                byte[] result = m_duel.QueryFieldCard(index, loc, flag, false);

                using (MemoryStream ms = new MemoryStream(result))
                {
                    BinaryReader reader = new BinaryReader(ms);
                    BinaryWriter writer = new BinaryWriter(ms);
                    while (ms.Position < ms.Length)
                    {
                        int len = reader.ReadInt32();
                        if (len == 4)
                            continue;
                        long pos = ms.Position;
                        reader.ReadBytes(len - 4);
                        long endPos = ms.Position;

                        ms.Position = pos;
                        ClientCard card = new ClientCard();
                        card.Update(reader);
                        ms.Position = endPos;

                        bool facedown = ((card.Position & (int)CardPosition.FaceDown) != 0);

                        using (GameServerPacket move = new GameServerPacket(GameMessage.Move))
                        {
                            move.Write(facedown ? 0 : card.Code);
                            move.Write(0);
                            move.Write((byte)card.Controler);
                            move.Write((byte)card.Location);
                            move.Write((byte)card.Sequence);
                            move.Write((byte)card.Position);
                            move.Write(0);
                            player.Send(move, false);
                        }
                        foreach (ClientCard material in card.Overlay)
                        {
                            using (GameServerPacket xyzcreate = new GameServerPacket(GameMessage.Move))
                            {
                                xyzcreate.Write(material.Code);
                                xyzcreate.Write(0);
                                xyzcreate.Write((byte)index);
                                xyzcreate.Write((byte)CardLocation.Grave);
                                xyzcreate.Write((byte)0);
                                xyzcreate.Write((byte)0);
                                xyzcreate.Write(0);
                                player.Send(xyzcreate, false);
                            }

                            using (GameServerPacket xyzmove = new GameServerPacket(GameMessage.Move))
                            {
                                xyzmove.Write(material.Code);
                                xyzmove.Write((byte)index);
                                xyzmove.Write((byte)CardLocation.Grave);
                                xyzmove.Write((byte)0);
                                xyzmove.Write((byte)0);
                                xyzmove.Write((byte)material.Controler);
                                xyzmove.Write((byte)material.Location);
                                xyzmove.Write((byte)material.Sequence);
                                xyzmove.Write((byte)material.Position);
                                xyzmove.Write(0);
                                player.Send(xyzmove, false);
                            }
                        }

                        if (facedown)
                        {
                            ms.Position = pos;
                            writer.Write(new byte[len - 4]);
                        }
                    }
                    writer.Close();
                    reader.Close();
                }
                if (loc == CardLocation.MonsterZone)
                {
                    result = m_duel.QueryFieldCard(index, loc, 0x81fff, false);
                    using (MemoryStream ms = new MemoryStream(result))
                    {
                        BinaryReader reader = new BinaryReader(ms);
                        BinaryWriter writer = new BinaryWriter(ms);
                        while (ms.Position < ms.Length)
                        {
                            int len = reader.ReadInt32();
                            if (len == 4)
                                continue;
                            long pos = ms.Position;
                            byte[] raw = reader.ReadBytes(len - 4);

                            bool facedown = ((raw[11] & (int)CardPosition.FaceDown) != 0);
                            if (facedown)
                            {
                                ms.Position = pos;
                                writer.Write(new byte[len - 4]);
                            }
                        }
                        reader.Close();
                        writer.Close();
                    }
                }
                using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData))
                {
                    update.Write((byte)index);
                    update.Write((byte)loc);
                    update.Write(result);
                    player.Send(update);
                }
            }
        }
コード例 #34
0
ファイル: ClientCard.cs プロジェクト: Zayelion/windbot
 public ClientCard(int id, CardLocation loc)
     : this(id, loc, 0)
 {
 }
コード例 #35
0
ファイル: GameAI.cs プロジェクト: 247321453/YgoServer
 public void SelectNextCard(CardLocation loc)
 {
     m_nextSelector = new CardSelector(loc);
 }
コード例 #36
0
ファイル: Duel.cs プロジェクト: 247321453/YgoServer
		public void AddCard(int cardId, int owner, CardLocation location)
		{
			Api.new_card(m_pDuel, (uint)cardId, (byte)owner, (byte)owner, (byte)location, 0, 0);
		}
コード例 #37
0
ファイル: Duel.cs プロジェクト: Zayelion/windbot
 public ClientCard GetCard(int player, CardLocation loc, int index)
 {
     return GetCard(player, (int)loc, index, 0);
 }
コード例 #38
0
ファイル: Duel.cs プロジェクト: Zayelion/windbot
 public void RemoveCard(CardLocation loc, ClientCard card, int player, int zone)
 {
     switch (loc)
     {
         case CardLocation.Hand:
             Fields[player].Hand.Remove(card);
             break;
         case CardLocation.Grave:
             Fields[player].Graveyard.Remove(card);
             break;
         case CardLocation.Removed:
             Fields[player].Banished.Remove(card);
             break;
         case CardLocation.MonsterZone:
             Fields[player].MonsterZone[zone] = null;
             break;
         case CardLocation.SpellZone:
             Fields[player].SpellZone[zone] = null;
             break;
         case CardLocation.Deck:
             Fields[player].Deck.Remove(card);
             break;
         case CardLocation.Extra:
             Fields[player].ExtraDeck.Remove(card);
             break;
     }
 }
コード例 #39
0
ファイル: Duel.cs プロジェクト: Ygocore/ygosharp_v0.1.1
 public int QueryFieldCount(int player, CardLocation location)
 {
     return Api.query_field_count(_duelPtr, (byte)player, (byte)location);
 }
コード例 #40
0
ファイル: Duel.cs プロジェクト: duelqiuqiu/DevBot
 public ClientCard GetCard(int player, CardLocation loc, int index)
 {
     switch (loc)
     {
         case CardLocation.SpellZone:
             return Fields[player].SpellZone[index];
         case CardLocation.MonsterZone:
             return Fields[player].MonsterZone[index];
         case CardLocation.Hand:
             if (Fields[player].Hand.Count > index)
                 return Fields[player].Hand[index];
             break;
         case CardLocation.Grave:
             if (Fields[player].Graveyard.Count > index)
                 return Fields[player].Graveyard[index];
             break;
         case CardLocation.Removed:
             if (Fields[player].Banished.Count > index)
                 return Fields[player].Banished[index];
             break;
         case CardLocation.Deck:
             if (Fields[player].Deck.Count > index)
                 return Fields[player].Deck[index];
             break;
         case CardLocation.Extra:
             if (Fields[player].ExtraDeck.Count > index)
                 return Fields[player].ExtraDeck[index];
             break;
     }
     return null;
 }
コード例 #41
0
ファイル: CardSelector.cs プロジェクト: Tic-Tac-Toc/windbot
 public CardSelector(CardLocation location)
 {
     _type = SelectType.Location;
     _location = location;
 }
コード例 #42
0
ファイル: GameAI.cs プロジェクト: 247321453/YgoServer
 public void SelectCard(CardLocation loc)
 {
     m_selector = new CardSelector(loc);
 }
コード例 #43
0
ファイル: Card.cs プロジェクト: bkgood/misc-code
 public void SetLocation(CardLocation location, int pileNum, int pileIndex)
 {
     if (pileNum < 0) {
         throw new ArgumentException(String.Format("pileNum must be positive or zero, got {0} for card {1}\n", pileNum, this));
     }
     if (pileIndex < 0) {
         throw new ArgumentException(String.Format("pileIndex must be positive or zero, got {0} for card {1}\n", pileIndex, this));
     }
     this.location = location;
     this.pileNum = pileNum;
     this.pileIndex = pileIndex;
     this.locationChanged = true;
 }
コード例 #44
0
ファイル: Duel.cs プロジェクト: Ygocore/ygosharp_v0.1.1
 public void AddTagCard(int cardId, int owner, CardLocation location)
 {
     Api.new_tag_card(_duelPtr, (uint)cardId, (byte)owner, (byte)location);
 }
コード例 #45
0
ファイル: Card.cs プロジェクト: bkgood/misc-code
 public void SetLocation(CardLocation location, int arg)
 {
     switch (location) {
         case CardLocation.Tableau:
             throw new ArgumentException("SetLocation must receive two int arguments for tableau locations.");
         case CardLocation.Foundation:
             SetLocation(location, arg, 0);
             break;
         case CardLocation.Stock:
             SetLocation(location);
             break;
         case CardLocation.Waste:
             SetLocation(location, 0, arg);
             break;
     }
 }
コード例 #46
0
ファイル: Duel.cs プロジェクト: Ygocore/ygosharp_v0.1.1
 public byte[] QueryFieldCard(int player, CardLocation location, int flag, bool useCache)
 {
     int len = Api.query_field_card(_duelPtr, (byte)player, (byte)location, flag, _buffer, useCache ? 1 : 0);
     byte[] result = new byte[len];
     Marshal.Copy(_buffer, result, 0, len);
     return result;
 }
コード例 #47
0
ファイル: Card.cs プロジェクト: bkgood/misc-code
 public void SetLocation(CardLocation location)
 {
     // somewhat unfortunate that these methods have to exist but the card must know where to draw itself
     if (location != CardLocation.Stock) {
         throw new ArgumentException("SetLocation must receive at least one int arguments for locations other than the stock.");
     }
     SetLocation(location, 0, 0);
 }