/// <summary> /// Loads all cards from a using a filepath /// </summary> /// <param name="filename"></param> /// <returns></returns> public static BGSScript LoadCard(string filePath) { XmlSerializer serializer = new XmlSerializer(typeof(BGSScript)); FileStream fs = new FileStream(filePath, FileMode.Open); BGSScript script = (BGSScript)serializer.Deserialize(fs); return(script); }
/// <summary> /// Saves a card to the file base. /// </summary> public static void SaveCard(BGSScript cardToSave, string filename) { XmlSerializer serializer = new XmlSerializer(typeof(BGSScript)); string filePath = defaultSavePath + filename + fileExtension; System.IO.TextWriter textWriter = new System.IO.StreamWriter(filePath); serializer.Serialize(textWriter, cardToSave); }
public Card TakeCard() //take the top card off the deck { if (_deck.Count == 0) { Debug.Log("drawing more cards than there are in deck"); return(null); // the deck is depleted } //creates a temporary card that is the card, then removes the card from the deck. Returns temporary card Card tempCard = _deck[0]; _deck.RemoveAt(0); return(tempCard); }
public Card TakeCard(Card card) //Retrieves a specific card from a deck. { if (_deck.Count == 0) { return(null); // the deck is depleted } // if (_deck.Remove(card)) //Only retrieves the card if it is in the deck. { return(card); } else { return(null); } }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="used"></param> /// <param name="cards"></param> public void DiscardCard(Card.ScriptType type, bool used, /*Card*/ Card card) { // TODO: detect card type if (!used) { switch (type) { case Card.ScriptType.Item: playerItems.TakeCard(card); break; case Card.ScriptType.Artifact: playerArtifacts.TakeCard(card); break; case Card.ScriptType.Event: playerEvents.TakeCard(card); break; case Card.ScriptType.Effect: playerEffects.TakeCard(card); break; } } else { switch (type) { case Card.ScriptType.Item: playerItemsUsed.TakeCard(card); break; case Card.ScriptType.Artifact: playerArtifactsUsed.TakeCard(card); break; case Card.ScriptType.Event: playerEventsUsed.TakeCard(card); break; case Card.ScriptType.Effect: playerEffectsUsed.TakeCard(card); break; } } }
/// <summary> /// Adds a card to a given part of the player's inventory /// </summary> /// <param name="type">Part of inventory to add card to</param> /// <param name="used">true if cards should be added to used part of inventory</param> /// <param name="card">Card to add</param> public void AddCard(Card.ScriptType type, bool used, /*CSL.Script*/ Card card) { //TODO: Automatically detect which part of inventory to put card in if (!used) { switch (type) { case Card.ScriptType.Item: playerItems.AddCard(card); break; case Card.ScriptType.Artifact: playerArtifacts.AddCard(card); break; case Card.ScriptType.Event: playerEvents.AddCard(card); break; case Card.ScriptType.Effect: playerEffects.AddCard(card); break; } } else { switch (type) { case Card.ScriptType.Item: playerItemsUsed.AddCard(card); break; case Card.ScriptType.Artifact: playerArtifactsUsed.AddCard(card); break; case Card.ScriptType.Event: playerEventsUsed.AddCard(card); break; case Card.ScriptType.Effect: playerEffectsUsed.AddCard(card); break; } } }
public List <Card> InsertCard(Card card, int index) //places a card in a specific place in the deck { _deck.Insert(index, card); return(_deck); }
public void AddCard(Card card) //adds input card to the "bottom" of the deck { _deck.Add(card); }