public TriggerEffectCommand(CardLogic playedCard, ICharacter target, Player owner, Table table) { this.playedCard = playedCard; this.target = target; this.owner = owner; this.table = table; }
public override void ActivateEffect(int specialAmount = 0, string specialName = "", ICharacter target = null) { int compteur; for (compteur = 0; compteur < specialAmount; compteur++) { CardAsset[] allCards = Resources.LoadAll <CardAsset> (""); CardAsset creature = null; foreach (CardAsset a in allCards) { if (a.Nom == specialName) { creature = a; break; } } if (TurnManager.Instance.whoseTurn.table.CreaturesOnTable.Count == 7) { return; } CardLogic creatureCard = new CardLogic(creature); // add a creature to player`s table: TurnManager.Instance.whoseTurn.PlayACreatureFromHand(creatureCard, tablePos: 0, causeBattlecry: false); } }
// depending on the current command being processed, the Actor may need to update its position to move // towards one of the waypoints; otherwise, return the current position to show that no movement is necessary private Vector3 FindTargetWaypoint() { if (current.Instruction == OpCode.INPUT) { return(InputWaypoint.transform.position); } else if (current.Instruction == OpCode.OUTPUT) { return(OutputWaypoint.transform.position); } else if (current.Instruction == OpCode.MOVE_TO || current.Instruction == OpCode.MOVE_FROM || current.Instruction == OpCode.COPY_TO || current.Instruction == OpCode.COPY_FROM || current.Instruction == OpCode.ADD || current.Instruction == OpCode.SUBTRACT || current.Instruction == OpCode.JUMP_IF_EQUAL || current.Instruction == OpCode.JUMP_IF_GREATER || current.Instruction == OpCode.JUMP_IF_LESS) { // retrieve the waypoint of the current card CurrentArg = current.Arg; CardLogic card = cardContainer.GetCard((int)CurrentArg); var waypoint = card.GetWaypoint(); waypoint.z = transform.position.z; return(waypoint); } return(transform.position); }
public void PlayCards(List <CardLogic> newCards) { Debug.Log("in PlayCards."); if (newCards.Count != 2) { Debug.LogError("ERROR: NetworkPlayer tried to PlayCards with " + newCards.Count + " cards"); //TODO: Make this fix the problem. } else { if (cardsPlayed != null && cardsPlayed.Count > 0) { while (cardsPlayed.Count > 0) { CardLogic card = cardsPlayed[0]; GameManager.Instance.DiscardItem(card); Debug.Log("Discarding Card: " + card.ToString()); cardsPlayed.Remove(card); } } foreach (CardLogic card in newCards) { cardsPlayed.Add(card); } if (cardsPlayed.Count != 2) { Debug.LogError("ERROR: After PlayCards, list of cardsPlayed.Count = " + cardsPlayed.Count); } } }
/// <summary> /// Inserts new random card into database. /// </summary> /// <param name="accountId"></param> /// <returns></returns> public bool InsertNewCard(int accountId) { using (SqlConnection connection = new SqlConnection(CONNECTION_STRING)) { try { connection.Open(); } catch (SqlException e) { Debug.WriteLine(e.Message); return(false); } string sqlQuery = @"INSERT INTO Cards (CardNumber, ExpDate, IsBlocked, PIN, AccountID) VALUES (@cardNumber, @expDate, 0, @pin, @accountID);"; SqlCommand command = new SqlCommand(sqlQuery, connection); command.Parameters.Add("@cardNumber", SqlDbType.NVarChar).Value = CardLogic.GenerateCardNum(); command.Parameters.Add("@expDate", SqlDbType.DateTime).Value = DateTime.Now.Add(TimeSpan.FromDays(1095)).ToShortDateString(); command.Parameters.Add("@pin", SqlDbType.VarChar).Value = CardLogic.GeneratePIN(); command.Parameters.Add("@accountID", SqlDbType.Int).Value = accountId; try { command.ExecuteNonQuery(); return(true); } catch (SqlException e) { Debug.WriteLine(e.Message); return(false); } } }
// draw a single card from the deck public void DrawACard(bool fast = false) { if (deck.cards.Count > 0) { if (hand.CardsInHand.Count < PArea.handVisual.slots.Children.Length) { // 1) logic: add card to hand CardLogic newCard = new CardLogic(deck.cards [0]); newCard.owner = this; hand.CardsInHand.Insert(0, newCard); // Debug.Log(hand.CardsInHand.Count); // 2) logic: remove the card from the deck deck.cards.RemoveAt(0); // 2) create a command //new DrawACardCommand (hand.CardsInHand [0], this, fast, fromDeck: true).AddToQueue (); new DrawACardCommand(newCard, this, fast, fromDeck: true).AddToQueue(); } } else { // there are no cards in the deck, take fatigue damage. /*Debug.Log("NO CARD IN DECK"); * fatigueDamageThisTurn++; * new DealDamageCommand(PlayerID, fatigueDamageThisTurn, this.Health - fatigueDamageThisTurn, Armor).AddToQueue(); * this.Health -= fatigueDamageThisTurn;*/ } }
private bool fromDeck; // is it from the deck? // Constructor public DrawCardAction(CardLogic cl, Player p, bool fast, bool fromDeck) { this.cl = cl; this.p = p; this.fast = fast; this.fromDeck = fromDeck; }
public void DrawHandCards(int num = 2) { if (!photonView.IsMine) { return; } for (int i = 0; i < num; ++i) { GameObject curr = Instantiate(Resources.Load <GameObject>("Prefabs/Card")); curr.transform.SetParent(myHand.transform, false); CardLogic cl = curr.GetComponent <CardLogic>(); cl.card = playerDeckCards[0].First; cl.cardInfo = playerDeckCards[0].Second; CardVisuals cv = curr.GetComponent <CardVisuals>(); cv.LoadCard(cl.card); //if (cl.cardInfo.doubleCast) // cv.descObj.text = cl.card.desc + " (DOUBLECAST)"; if (cl.cardInfo.exhausted) { cv.titleObj.text = cl.card.title + " (EXHAUSTED)"; } playerDeckCards.Remove(playerDeckCards[0]); } }
public GameObject ShowCardPreview(Card card, CardInfo cardInfo, string previewObjName = "Canvas/CardPreview") { if (previewObjName == "Canvas/CardPreview") { previewObj = GameObject.Find(previewObjName); } GameObject curr = Instantiate(Resources.Load <GameObject>("Prefabs/Card")); curr.transform.SetParent(previewObj.transform, false); curr.transform.localScale = new Vector3(1.4f, 1.4f, 1); CardLogic cl = curr.GetComponent <CardLogic>(); cl.enabled = false; CardVisuals cv = curr.GetComponent <CardVisuals>(); cv.LoadCard(card); //if (cardInfo.doubleCast) // cv.descObj.text = card.desc + " (DOUBLECAST)"; if (cardInfo.exhausted) { cv.titleObj.text = card.title + " (EXHAUSTED)"; } return(curr); }
public void SummonACreature(CardLogic cardLogic, Tile tile) { // Withdraw from Players Resources manaCount -= cardLogic.currentManaCost; bloodCount -= cardLogic.currentBloodCost; earthCount -= cardLogic.currentEarthCost; // Update visual player resources playerVisual.resourcesVisual.SetResourcesVisual(manaCount, bloodCount, earthCount); // Create CreatureLogic and add it to the table. CreatureLogic newCreature = new CreatureLogic(this, cardLogic.cardAsset); // Add the CreatureLogic to the table Logic at the tile. Table.instance.AddCreatureToTile(newCreature, tile); new SummonACreatureCommand(cardLogic, this, tile, newCreature.uniqueCreatureID).AddToQueue(); if (newCreature.effect != null) { // newCreature.effect.WhenACreatureIsPlayed(); } playerState = PlayerState.Idle; cardToBeSummoned = null; }
public void PlaySpellFromHand(CardLogic playedCard, ICharacter target) { ManaLeft -= playedCard.CurrentManaCost; playedCard.ActivateCardEffect(target); new PlayASpellCardCommand(this, playedCard).AddToQueue(); hand.CardsInHand.Remove(playedCard); }
public void InitialiseCard(CardInfo info) { // setup card graphics _cardInfo = info; _cardIcon.sprite = _cardInfo.CardIcon; _cardName.text = _cardInfo.CardName; _cardDescription.text = _cardInfo.CardDescription; _cardType = _cardInfo.CardType; _cardTypeText.text = _cardType.GetTypeString(); // setup card logic _cardAttributes = _cardInfo.CardAttributes; _cardCostValue.text = _cardAttributes.BaseCardCost.ToString(); _cardType.OnInitCard(); try { _cardLogic = this.gameObject.GetComponent <CardLogic>(); } catch (NullReferenceException e) { Debug.Log("card does not have accompanying logic. Adding class..."); var temp = this.gameObject.AddComponent <CardLogic>(); _cardLogic = temp; } }
public PlayACreatureCommand(CardLogic cardLogic, Player player, int tablePos, int creatureID) { this._player = player; this._cardLogic = cardLogic; this._tablePos = tablePos; this._creatureID = creatureID; }
public CardLogic DealCard() { CardLogic newCard = new CardLogic(cards[0]); cards.RemoveAt(0); return(newCard); }
private void loadCardFromEvent(GameObject card, CardLogic cl) { OneCardManager cardManager = card.GetComponent <OneCardManager>(); cardManager.cardAsset = cl.ca; cardManager.ReadCardFromAsset(); }
public void ReturnCardToHandFrom(int index, GameObject card, Player p) { CardLogic cl; if (p == null) { p = Player.Instance; } if (index == 0) { cl = SlotLeft; new TakeCardBackCommand(cl, card, p).AddToQueue(); SlotLeft = null; } else if (index == 1) { cl = SlotRight; new TakeCardBackCommand(cl, card, p).AddToQueue(); SlotRight = null; } else { Debug.LogError("ReturnCardToHandFrom called with out of bounds index: " + index); return; } }
public TakeCardBackCommand(CardLogic cl, GameObject card, Player p) { this.cl = cl; this.p = p; this.card = card; Debug.Log("Creating TakeCardBackCommand with cl: " + cl.ToString() + " p: " + p.ToString() + " card: " + card.ToString()); }
static void Main(string[] args) { Console.WriteLine("Welcome to the card shuffler and sorter!"); Console.WriteLine("Would you like to sort an out-of-order deck or shuffle a sorted deck? Enter \"sort\" or \"shuffle\" to choose."); var input = Console.ReadLine(); while (!InputLogic.IsInputValid(input)) { Console.WriteLine("Sorry, that's not a valid request, please try again."); input = Console.ReadLine(); } while (InputLogic.IsInputValid(input)) { var deckToProcess = InputLogic.RetrieveDeckToProcess(input); var output = InputLogic.Execute(input, deckToProcess); Console.WriteLine("Here's the initial deck:"); CardLogic.DeckPrinter(deckToProcess); Console.WriteLine(); Console.WriteLine("Here's the new deck:"); CardLogic.DeckPrinter(output); Console.WriteLine("Would you like to see another deck? Enter \"sort\", \"shuffle\", or any value to exit."); input = Console.ReadLine(); } }
public override void OnStartDrag() { DebugManager.Instance.DebugMessage("Beginning to drag a spell.", DebugManager.MessageType.PlayerInteraction, gameObject); savedHandSlot = whereIsCard.Slot; whereIsCard.VisualState = VisualStates.Dragging; whereIsCard.BringToFront(); int ID = transform.GetComponent <IDHolder>().uniqueID; Player p = TurnManager.Instance.WhoseTurn; CardLogic cl = null; foreach (CardLogic c in p.hand.cardsInHand) { if (c.ID == ID) { cl = c; } } CardActionManager.Instance.HighlightValidTargets(TurnManager.Instance.WhoseTurn, cl); DebugManager.Instance.DebugMessage("Highlighting entire table.", DebugManager.MessageType.Targeting); CardActionManager.Instance.HighlightValidTargets(p, cl); }
// draw a single card from the deck public void DrawACard(bool fast = false) { if (deck.cards.Count > 0) { if (hand.cardsInHand.Count < PArea.handVisual.slots.Children.Length) { // 1) logic: add card to hand CardLogic newCard = new CardLogic(deck.cards[0]) { owner = this }; DebugManager.Instance.DebugMessage("Creating a new card: " + newCard.ca.name, DebugManager.MessageType.Creation); hand.cardsInHand.Insert(0, newCard); // Debug.Log(hand.CardsInHand.Count); // 2) logic: remove the card from the deck deck.cards.RemoveAt(0); // 2) create a command new DrawACardCommand(hand.cardsInHand[0], this, fast, fromDeck: true).AddToQueue(); } } else { // there are no cards in the deck, take fatigue damage. } }
public override void OnTurnStart() { //Trigger boss ability at 1st health threshold if (bossState == 0 && p.Health <= 20) { //p.GetACardNotFromDeck(ca1); //p.GetACardNotFromDeck(ca1); new ShowMessageCommand("LIMIT BREAK! \n eBot Army", 2.0f).AddToQueue(); CardLogic cl1 = new CardLogic(ca1); CardLogic cl2 = new CardLogic(ca1); Debug.Log(cl1.ca.name); p.PlayACreatureFromHand(cl1, 0); InsertDelay(1.5f); p.PlayACreatureFromHand(cl2, 0); InsertDelay(1.5f); bossState++; } //Trigger boss ability at 2nd health threshold if (bossState == 1 && p.Health <= 10) { new ShowMessageCommand("LIMIT BREAK! \n eBot Army", 2.0f).AddToQueue(); CardLogic cl1 = new CardLogic(ca1); CardLogic cl2 = new CardLogic(ca1); p.PlayACreatureFromHand(cl1, 0); InsertDelay(1.5f); p.PlayACreatureFromHand(cl2, 0); InsertDelay(1.5f); bossState++; } base.OnTurnStart(); }
public void TimesUp() { Debug.Log("times Up!"); // TODO: Implement "locking in cards" List <CardLogic> selectedCards = new List <CardLogic>(); Table t = Table.Instance; if (t.SlotLeft == null) { Debug.Log("t.SlotLeft == null"); Slot leftSlot = TableVisual.Instance.leftSlot.GetComponent <Slot>(); CardLogic newCard = GameManager.Instance.itemDeck.DealCard(); new PlayItemFromDeckCommand(newCard, Player.Instance, true, leftSlot).AddToQueue(); t.SlotLeft = newCard; } if (t.SlotRight == null) { Debug.Log("t.SlotRight == null"); Slot rightSlot = TableVisual.Instance.rightSlot.GetComponent <Slot>(); CardLogic newCard = GameManager.Instance.itemDeck.DealCard(); new PlayItemFromDeckCommand(newCard, Player.Instance, true, rightSlot).AddToQueue(); t.SlotRight = newCard; } selectedCards.Add(t.SlotLeft); selectedCards.Add(t.SlotRight); GameManager.Instance.getPlayerByID(GameManager.Instance.localPlayer).PlayCards(selectedCards); GameManager.Instance.playItemsForAI(); StartCoroutine(GameManager.Instance.endCurrentEventAfterDuration(5.0f)); //Clear Slots. //End Event. }
// Excès de rage public override void WhenACreatureIsPlayed() { List <CardAsset> allCreatureAssets = new List <CardAsset>(); CardAsset[] allCards = Resources.LoadAll <CardAsset>(""); // only select creatures foreach (CardAsset a in allCards) { if (a.VieMaximum > 0) { allCreatureAssets.Add(a); } } if (owner.table.CreaturesOnTable.Count == 7) { return; } // Select a random CardAsset: int index = Random.Range(0, allCreatureAssets.Count); CardAsset randomCreatureAsset = allCreatureAssets[index]; // make a CardLogic to call PlayACreatureFromHand(): CardLogic creatureCard = new CardLogic(randomCreatureAsset); // add a creature to player`s table: owner.PlayACreatureFromHand(creatureCard, tablePos: 0, causeBattlecry: false); // or you can change it to: tablePos: 6 to place him on the other side. }
public void DrawACard(bool fast = false) { if (deck.cards.Count > 0) { if (hand.CardsInHand.Count < PArea.handVisual.slots.Children.Length) { // 1) save index to place a visual card into visual hand int indexToPlaceACard = hand.CardsInHand.Count; // 2) logic: add card to hand CardLogic newCard = new CardLogic(deck.cards[0]); newCard.owner = this; hand.CardsInHand.Add(newCard); // Debug.Log(hand.CardsInHand.Count); // 3) logic: remove the card from the deck deck.cards.RemoveAt(0); // 4) create a command deck.nextCards.Add(newCard.ca); new DrawACardCommand(hand.CardsInHand[indexToPlaceACard], this, indexToPlaceACard, fast, fromDeck: true).AddToQueue(); } } else { deck.cards = new List <Cards>(deck.nextCards); deck.nextCards.Clear(); deck.cards.Shuffle(); DrawACard(); } }
public DrawACardCommand(CardLogic cl, Player p, bool fast, bool fromDeck) { this.cl = cl; this.p = p; this.fast = fast; this.fromDeck = fromDeck; }
public PlayAnItemCommand(CardLogic cl, Player p, int tablePos, int cardID) { this.p = p; this.cl = cl; this.tablePos = tablePos; this.cardID = cardID; }
// place the currently held value in the specified Card IEnumerator MOVE_TO() { // grab card reference CurrentArg = current.Arg; CardLogic card = cardContainer.GetCard((int)CurrentArg); HideDataCube(); // trying to store null causes a runtime error if (CurrentValue == null) { error = true; currentState = ACTOR_STATE.REPORTING; yield return(StartCoroutine(currentState.ToString())); } else { // put down the value held, and hands are now empty card.MoveTo((int)CurrentValue); CurrentValue = null; yield return(new WaitForSeconds(InstructionDelay)); } currentState = ACTOR_STATE.REPORTING; }
public DrawACardCommand(CardLogic cardLogic, Player player, bool fast, bool fromDeck) { this._cardLogic = cardLogic; this._player = player; this._fast = fast; this._fromDeck = fromDeck; }
public PlayACreatureCommand(CardLogic cl, Player p, int tablePos, int creatureID) { this._p = p; this._cl = cl; this._tablePos = tablePos; this._creatureId = creatureID; }
public PlayItemFromDeckCommand(CardLogic cl, Player p, bool fast, Slot toSlot) { this.cl = cl; this.p = p; this.fast = fast; this.toSlot = toSlot; }
protected void Page_Load(object sender, EventArgs e) { if (Session["logic"] == null) { logic = new CardLogic(); Session["logic"] = logic; } else logic = (CardLogic)Session["logic"]; }
protected void Page_Load(object sender, EventArgs e) { if (Session["logic"] == null) { logic = new CardLogic(); Session["logic"] = logic; } else logic = (CardLogic)Session["logic"]; logic.setDecks(1); GridViewDeck.DataSource = logic.decks as IEnumerable<Deck>; GridViewDeck.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { logic = new CardLogic(); logic.setDecks(1); int deckId = (int)Session["deckId"]; int deckIndex = logic.decks.FindIndex(x => x.deckId == deckId); logic.setCardsInActiveDeck(deckId); deckName.Text = "Deck Name: " + logic.decks[deckIndex].name; deckClass.Text = "Deck Class: " + logic.decks[deckIndex].playerClass; List<String> filePaths = logic.getCardImageUrls(); cardRepeater.DataSource = filePaths; cardRepeater.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { //Logic olio tallennetaan sessiooon että sinne tallennettuja tietoja voidaan käyttää sivun //uudelleen rakentumisen jälkeen if (!IsPostBack) { if (Session["logic"] == null) { logic = new CardLogic(); Session["logic"] = logic; } else logic = (CardLogic)Session["logic"]; logic.divideAndConquer("Druid"); setPictures(logic.index); } else { logic = (CardLogic)(Session["logic"]); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { druidCards.Style["display"] = "none"; hunterCards.Style["display"] = "none"; mageCards.Style["display"] = "none"; paladinCards.Style["display"] = "none"; priestCards.Style["display"] = "none"; rogueCards.Style["display"] = "none"; shamanCards.Style["display"] = "none"; warlockCards.Style["display"] = "none"; warriorCards.Style["display"] = "none"; String classButtonName = ((string)(Session["class"])).ToLower() + "Cards"; Button button = this.Master.FindControl("ContentPlaceHolder1").FindControl(classButtonName) as Button; if (button != null) { button.Style["display"] = "visible"; } if (Session["logic"] == null) { logic = new CardLogic(); Session["logic"] = logic; } else logic = (CardLogic)Session["logic"]; Session["cardsInDeck"] = logic.cardsInDeck; //User id pitää vaihtaa kun saa loginin tehtyä // logic.startDeck((string)(Session["class"]),1); logic.divideAndConquer((string)(Session["class"])); setPictures(logic.index); GridViewDeck.DataSource = logic.cardsInDeck as IEnumerable<Card>; GridViewDeck.DataBind(); } else { logic = (CardLogic)(Session["logic"]); logic.cardsInDeck = (List<Card>)(Session["cardsInDeck"]); GridViewDeck.DataSource = logic.cardsInDeck as IEnumerable<Card>; GridViewDeck.DataBind(); } }