Comments (6)
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.
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.
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.
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.
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.
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)
- Build issue HOT 3
- bug of SabberStoneGui HOT 2
- Can't run a game on GUI. HOT 1
- Unix - antlr4 doesn't suceed to parse the HSGrammar.g4
- Molten Blade cost doesn't change upon transformation HOT 3
- I don't know about running code with game HOT 1
- Bug in playing cards when board is full (CoreAI) HOT 12
- Upcoming mechanic changes to Multi-Target Cards HOT 1
- Some wiki pages are not accessible HOT 5
- How to simulate the game board state, and run for analyze HOT 4
- Could not load file or assembly System.Runtime.CompilerServices.Unsafe HOT 3
- Add global exception handler for SabberStoneGui HOT 1
- Game Point of View of Player HOT 3
- How to use Unity3D client? HOT 1
- Casting error from Enchantment to ICharacter. HOT 5
- You only use ATK.Effect when tag == GameTag.ATK, what is the reason? HOT 5
- Cardset for the new Classic mode of Hearthstone HOT 5
- Some cards from EXPERT1 (classic) are not implemented? HOT 4
- Can't run SabberStoneConsole, dotnet.exe error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sabberstone.