private void RedrawCardBtn_Click(object sender, EventArgs e) { int?cost; if (int.TryParse(CostTextBox.Text, out int i)) { if (i > 4 || i <= 0) { cost = null; } else { cost = i; } } else { cost = null; } InvestigatorCard card = Draw((InvestigatorCardType)CardTypeBox.SelectedIndex, TraitsTextBox.Text, cost, blacklist); if (card != null) { blacklist.Add(card); DisplayDrawnCard(card); } else { DisplayNoDrawMessage(); } lastCard = card; }
public void InitPlayer(InvestigatorCard card) { m_investigatorCard = card; // 如果有父对象被摧毁,其子对象也会被摧毁 m_investigatorCard.transform.SetParent(null); GameObject.DontDestroyOnLoad(m_investigatorCard); m_health = m_investigatorCard.m_health; m_sanity = m_investigatorCard.m_sanity; }
/// <summary> /// Displays the drawn card. /// </summary> /// <param name="card"></param> private void DisplayDrawnCard(InvestigatorCard card) { string msg = string.Format("Name: {0}\nType: {1}\nTraits: {2}", card.Name, card.CardType, string.Join(", ", card.Traits)); if (card is AssetCard) { msg += string.Format("\nCost: {0}", ((AssetCard)card).Cost); } CardDrawLabel.Text = msg; }
/// <summary> /// Parses a HTML table in file to get all the card data listed within. /// </summary> /// <param name="filepath"></param> /// <param name="type"></param> /// <returns></returns> private static IEnumerable <InvestigatorCard> Parse(string filepath, InvestigatorCardType type) { List <InvestigatorCard> cards = new List <InvestigatorCard>(); HtmlDocument doc = new HtmlDocument(); doc.Load(filepath); foreach (HtmlNode rowNode in doc.DocumentNode.Descendants("tr")) { IEnumerable <HtmlNode> cardNodes = rowNode.Descendants("td"); string name = cardNodes.ElementAt(0).InnerText.Trim(); string traitsString = cardNodes.ElementAt(1).InnerText.Replace('-', ',').Replace('—', ','); HtmlNode expNode = cardNodes.ElementAt(2); HtmlNode expLinkNode = expNode.SelectSingleNode(".//a"); string expString = "Core"; if (expLinkNode != null) { expString = expLinkNode.GetAttributeValue("title", "Core"); } List <string> traits = new List <string>(); foreach (string traitRaw in traitsString.Split(',')) { traits.Add(traitRaw.ToUpper().Trim()); } Expansion exp = ExpansionExtensions.FromString(expString); InvestigatorCard card; if (type == InvestigatorCardType.Asset) { int cost = int.Parse(cardNodes.ElementAt(3).InnerText); card = new AssetCard(name, type, exp, traits, cost); } else { card = new InvestigatorCard(name, type, exp, traits); } cards.Add(card); } return(cards); }
public Main() { InitializeComponent(); cards = OpeningWindow.COLLECTION; blacklist = new List <InvestigatorCard>(); lastCard = null; discardDataGridSource = new BindingList <InvestigatorCard>(); DiscardsDataGrid.DataSource = discardDataGridSource; foreach (InvestigatorCard card in cards.InDeck) { if (cards.Discards[card] > 0) { discardDataGridSource.Add(card); } } MessageBox.Show("Active expansions:\n" + string.Join("\n", cards.ExpansionsInUse)); foreach (InvestigatorCardType type in Enum.GetValues(typeof(InvestigatorCardType))) { CardTypeBox.Items.Add(type); } CardTypeBox.SelectedIndex = 0; Tooltip.SetToolTip(TraitsTextBox, "Enter tags (the block-capital bold italicised text like ITEM or RITUAL) here.\n" + "Add multiple with spaces between to only draw a card with all of those tags (EG: 'ITEM MAGICAL RELIC').\n" + "Use parentheses to select any of the contained tags (EG: '(ITEM TRINKET) TOME' to get either an ITEM TOME or TRINKET TOME.)"); Tooltip.SetToolTip(CostTextBox, "Only applies to assets. Range is 1-4. Anything outside this range or not a number will be ignored."); Tooltip.SetToolTip(RedrawCardBtn, "Discards/shuffles back the current card as appropriate for it's type and draws a new one that will not have the same name as this or any other " + "cards drawn since the last draw."); Tooltip.SetToolTip(KeepCardBtn, "When this is clicked, the last card drawn will be considered kept and will be removed from the pool, preventing it from appearing in the future.\n" + "This can be undone in the 'Removed' tab."); }
private void KeepCardBtn_Click(object sender, EventArgs e) { if (lastCard != null) { //if (lastCard.CardType == InvestigatorCardType.Artifact || lastCard.CardType == InvestigatorCardType.Asset || // (lastCard.CardType == InvestigatorCardType.UniqueAsset && lastCard.GetQuantity(ExpansionExtensions.GetAllExpansions()) == 1)) //{ cards.Discards[lastCard] += 1; blacklist = new List <InvestigatorCard>(); CardDrawLabel.Text = "Card removed from pool."; discardDataGridSource.Add(lastCard); lastCard = null; //} //else //{ // CardDrawLabel.Text = "This type of card cannot be removed from the pool."; //} } else { CardDrawLabel.Text = "No card selected."; } }
/// <summary> /// Returns true if the card matches the predicate. /// </summary> /// <param name="card"></param> /// <returns></returns> public bool IsValid(InvestigatorCard card) { return(lp.IsMatch(card.Traits)); }
public void LoadGameData() { cardsInGameRepository.Reset(); LoadScenarioCards(); LoadInvestigatorsCardsAndPlayers(); LoadZones(); SetCardsInZone(); void LoadScenarioCards() { foreach (string cardType in gameFiles.ALL_SCENARIO_CARDS_FILES) { string encounterPath = gameFiles.DeckPath(campaignRepository.CurrentScenario.Id) + cardType; serializer.CreateDataFromResources <List <string> >(encounterPath).ForEach(cardId => MapCard(cardId)); } } void LoadInvestigatorsCardsAndPlayers() { playersRepository.Reset(); foreach (Investigator investigator in selectorRepository.InvestigatorsInSelector) { InvestigatorCard investigatorCard = MapCard(investigator.Id) as InvestigatorCard; Player newPlayer = new Player(investigatorCard); investigator.FullDeckId.ForEach(cardId => newPlayer.AddCardInDeck(MapCard(cardId))); playersRepository.AddPlayer(newPlayer); } } Card MapCard(string cardId) { Card newCard = factory.CreateInstance <Card>(cardId); newCard.CreateWithThisCard(cardRepository.Get(cardId)); return(newCard); } void LoadZones() { zonesRepository.Reset(); zonesRepository.Add(zonesRepository.EncounterZone); zonesRepository.Add(zonesRepository.DiscardZone); zonesRepository.Add(zonesRepository.ScenarioZone); zonesRepository.Add(zonesRepository.ActZone); zonesRepository.Add(zonesRepository.AgendaZone); zonesRepository.Add(zonesRepository.PlayingZone); zonesRepository.Add(zonesRepository.SkillTestZone); zonesRepository.Add(zonesRepository.OutSideZone); zonesRepository.Add(zonesRepository.VictoryZone); for (int i = 0; i < 12; i++) { zonesRepository.Locations.Add(new Zone(ZoneType.Location)); } zonesRepository.AddRange(zonesRepository.Locations); foreach (Player player in playersRepository.AllPlayers) { zonesRepository.Add(player.InvestigatorZone); zonesRepository.Add(player.HandZone); zonesRepository.Add(player.DeckZone); zonesRepository.Add(player.DiscardZone); zonesRepository.Add(player.AssetZone); zonesRepository.Add(player.ThreatZone); } zonesRepository.AddRange(cardsInGameRepository.AllListCards.Select(card => card.CardZone)); } void SetCardsInZone() { foreach (Card card in cardsInGameRepository.AllListCards) { zonesRepository.OutSideZone.EnterThisCard(card); } } }