Commit 344201b4 authored by Liza's avatar Liza

Add immunity gene; check gene count in snail creation test

parent 6a030e4c
Pipeline #63131307 (#498) passed with stages
in 20 minutes and 35 seconds
......@@ -8,6 +8,7 @@ import (
var GeneRegistry = map[string]reflect.Type{
"size_a1": reflect.TypeOf(SizeA1{}),
"maturity_a1": reflect.TypeOf(MaturityA1{}),
"immunity_a1": reflect.TypeOf(ImmunityA1{}),
}
func InstantiateGene(t reflect.Type) (organism.Gene, error) {
......
package gene
import (
"gitlab.com/drakonka/gosnaillife/common/domain/organism"
"gitlab.com/drakonka/gosnaillife/common/domain/snail/organ"
"reflect"
)
type ImmunityA1 struct {
organism.GeneBase
}
func (g *ImmunityA1) Init() error {
g.Id = "immunity_a1"
g.DominanceType = organism.Complete
var e *SizeA1Expresser
g.Expresser = reflect.TypeOf(e).Elem()
g.PossibleAlleles = g.getVariations()
return nil
}
func (g *ImmunityA1) GetGeneId() string {
return g.Id
}
func (g *ImmunityA1) getVariations() organism.Alleles {
// Variations are "Suppressed", "Standard", and "Enhanced"
// Standard
standardA := Allele{
GeneId: g.Id,
Key: "S",
}
standardA.Modifier = 0.00
standardA.DominanceLevel = 2
suppressedA := Allele{
GeneId: g.Id,
Key: "s",
}
suppressedA.Modifier = 0.5
suppressedA.DominanceLevel = 1
enhancedA := Allele{
GeneId: g.Id,
Key: "e",
}
enhancedA.Modifier = 1.00
enhancedA.DominanceLevel = 0
return organism.Alleles{&standardA, &suppressedA, &enhancedA}
}
type ImmunityA1Expresser interface {
ExpressSizeA1(o *organ.Organ) error
}
......@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/golang/mock/gomock"
"gitlab.com/drakonka/gosnaillife/common/domain/snail"
"gitlab.com/drakonka/gosnaillife/common/domain/snail/gene"
testing2 "gitlab.com/drakonka/gosnaillife/common/util/testing"
repo2 "gitlab.com/drakonka/gosnaillife/server/lib/infrastructure/repo"
mock_repo "gitlab.com/drakonka/gosnaillife/server/lib/infrastructure/repo/mocks"
......@@ -66,12 +67,19 @@ func TestGenerateRandomSnail(t *testing.T) {
return
}
wantedGenes := len(gene.GeneRegistry)
for _, g := range s.Genes() {
alleles := g.GetAlleles()
if alleles == nil || len(alleles) == 0 {
t.Error(testing2.TCFailedMsg("CreationTest", tc.name, fmt.Sprintf("gene %s has no alleles", g.GeneId())))
}
wantedGenes -= 1
}
if wantedGenes > 0 {
msg := fmt.Sprintf("Some genes were missing. Found: %v", s.Genes())
t.Error(testing2.TCFailedMsg("CreationTest", tc.name, msg))
}
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment