-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
81 additions
and
47 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cardobject | ||
|
||
import ( | ||
"errors" | ||
"strconv" | ||
|
||
"github.com/DecentralCardGame/cardobject/jsonschema" | ||
) | ||
|
||
const maxRulesTextLength int = 1000 | ||
const minRulesTextLength int = 0 | ||
|
||
type RulesTexts []RulesText | ||
|
||
func (r RulesTexts) Validate() error { | ||
return r.ValidateArray() | ||
} | ||
|
||
func (r RulesTexts) ValidateArray() error { | ||
errorRange := []error{} | ||
for _, v := range r { | ||
err := v.Validate() | ||
if err != nil { | ||
errorRange = append(errorRange, err) | ||
} | ||
} | ||
return jsonschema.CombineErrors(errorRange) | ||
} | ||
|
||
func (r RulesTexts) MinMaxItems() (int, int) { | ||
return 0, 3 | ||
} | ||
|
||
func (r RulesTexts) ItemName() string { | ||
return jsonschema.ItemNameFromArray(r) | ||
} | ||
|
||
type RulesText jsonschema.BasicString | ||
|
||
func (r RulesText) Validate() error { | ||
return r.ValidateString() | ||
} | ||
|
||
func (r RulesText) ValidateString() error { | ||
minLength, maxLength := r.MinMaxLength() | ||
length := len(string(r)) | ||
if length < minLength || length > maxLength { | ||
return errors.New("RulesText must be between " + strconv.Itoa(minLength) + " and " + strconv.Itoa(maxLength) + " characters long") | ||
} | ||
return nil | ||
} | ||
|
||
func (r RulesText) MinMaxLength() (int, int) { | ||
return minRulesTextLength, maxRulesTextLength | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"Place":{"CardName":"Mühle","CastingCost":2,"RulesText": "This could be your RulesText","Class":{"Nature":false,"Mysticism":false,"Technology":true,"Culture":false},"Abilities":[],"Health":3,"FlavourText":"lulul","Tags":["PRIMITIVE"]}} | ||
{"Place":{"CardName":"Mühle","CastingCost":2,"RulesTexts": ["This could be your RulesText"],"Class":{"Nature":false,"Mysticism":false,"Technology":true,"Culture":false},"Abilities":[],"Health":3,"FlavourText":"lulul","Tags":["PRIMITIVE"]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"Entity":{"CardName":"Name","CastingCost":13,"Class":{"Nature":false,"Mysticism":false,"Technology":true,"Culture":false},"Abilities":[{"ActivatedAbility":{"AbilityCost":{"ManaCost":{"CostAmount":2}},"Effects":[{"TargetEffect":{"EntityTargetEffect":{"EntitySelector":{"PlayerMode":"YOU","CardMode":"TARGET","EntityZone":"FIELD"},"EntityManipulations":[{"EntityIntManipulation":{"IntProperty":"HEALTH","IntOperator":"ADD","IntValue":{"SimpleIntValue":2},"Keyword":"ARM"}},{"EntityIntManipulation":{"IntProperty":"ATTACK","IntOperator":"ADD","IntValue":{"SimpleIntValue":2},"Keyword":"ARM"}}]}}}]}}],"Attack":10,"Health":10,"FlavourText":"-.-","Tags":["SPIRITUAL"],"Keywords":["ARM","PAY"],"RulesText":"This could be your RulesText"}} | ||
{"Entity":{"CardName":"Name","CastingCost":13,"Class":{"Nature":false,"Mysticism":false,"Technology":true,"Culture":false},"Abilities":[{"ActivatedAbility":{"AbilityCost":{"ManaCost":{"CostAmount":2}},"Effects":[{"TargetEffect":{"EntityTargetEffect":{"EntitySelector":{"PlayerMode":"YOU","CardMode":"TARGET","EntityZone":"FIELD"},"EntityManipulations":[{"EntityIntManipulation":{"IntProperty":"HEALTH","IntOperator":"ADD","IntValue":{"SimpleIntValue":2},"Keyword":"ARM"}},{"EntityIntManipulation":{"IntProperty":"ATTACK","IntOperator":"ADD","IntValue":{"SimpleIntValue":2},"Keyword":"ARM"}}]}}}]}}],"Attack":10,"Health":10,"FlavourText":"-.-","Tags":["SPIRITUAL"],"Keywords":["ARM","PAY"],"RulesTexts":["This could be your RulesText",""]}} |