GithubHelp home page GithubHelp logo

Comments (6)

chucklu avatar chucklu commented on May 18, 2024

The following method should use First instead of FirstOrDefault

public static Card FromName(string cardName)
		{
			return Data.Cards.FirstOrDefault(x => x.Value.Name == cardName && x.Value.Collectible).Value;
		}

Currently when I switch the language of Cards to zhCN
https://github.com/HearthSim/SabberStone/blob/master/SabberStoneCoreTest/src/CardSets/LootapaloozaCardsGenTest.cs#L2084

	var game = new Game(new GameConfig
			{
				StartPlayer = 1,
				Player1HeroClass = CardClass.PRIEST,
				Player1Deck = new List<Card>()
				{
					Cards.FromName("Lesser Diamond Spellstone"),
				},
				Player2HeroClass = CardClass.PRIEST,
				Shuffle = false,
				FillDecks = true,
				FillDecksPredictably = true
			});

The above code Player1Deck will get a deck list with a null item in it.

from sabberstone.

rnilva avatar rnilva commented on May 18, 2024

If you change it to First it throws an exception instead of returning null.
I would like to add functionality that allows users to have some controls over parsing cards, for example, someone may want to load only specific cardsets etc. I am considering which form would we have for the functionality.

from sabberstone.

chucklu avatar chucklu commented on May 18, 2024

Yes, I think it should throw exception if we can not find the card. Otherwise it's too late when I find the card is null.
If someone want to load cards from specific card set, we might provide another method with two parameters, card name and card set.

How do you think about the language setting for Cards?
Currently, the cards were loaded in static constructor static Cards(), I did not have a chance to modify it outside the Cards class.

from sabberstone.

rnilva avatar rnilva commented on May 18, 2024

Currently static class Cards would implicitly be constructed when the first time it is called, using the static constructor you mentioned. I think if we have an explicit generator function for Cards it would work... like Cards.Generate() and make users call it before creating his/her first Game object and otherwise, it should be called implicitly like the current scheme. Maybe there are more neat designs?

from sabberstone.

chucklu avatar chucklu commented on May 18, 2024

Maybe we can get the language from App.config in static constructor? Add a app setting with key Language or CardLanguage, then read it from config file.
Otherwise we need provide a reload method for Cards class, and the method with one parameter language.

from sabberstone.

chucklu avatar chucklu commented on May 18, 2024

From another repository, I find the card implementation https://github.com/HearthSim/HearthDb/blob/master/HearthDb/Card.cs#L26
It supports the language setting on card level, we might take this design.

from sabberstone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.