Example #1
0
func init() {
	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		wood, stone, metal := material.Get()
		if len(wood) != 0 {
			return nil
		}
		if s == "stone" && len(stone) != 0 && len(metal) == 0 {
			return &Stone{
				material: material,
			}
		}
		if s == "ore" && len(stone) == 0 && len(metal) != 0 {
			return &Ore{
				material: material,
			}
		}
		if len(stone) == 0 {
			return nil
		}
		if s == "rock" {
			return &Rock{
				material: material,
			}
		}
		if s == "deposit" && len(metal) != 0 {
			return &Rock{
				material: material,
				rich:     true,
			}
		}
		return nil
	}))
}
Example #2
0
func init() {
	world.Register("door", world.Visible((*Door)(nil)))
	world.RegisterSpawnFunc(func(s string) world.Visible {
		if s == "door" {
			return &Door{}
		}
		return nil
	})
}
Example #3
0
func init() {
	world.Register("forge", world.Visible((*Forge)(nil)))
	world.RegisterSpawnFunc(func(s string) world.Visible {
		if s == "forge" {
			return &Forge{}
		}
		return nil
	})
}
Example #4
0
func init() {
	world.Register("floor", world.Visible((*Floor)(nil)))
	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		if s == "floor" {
			return &Floor{
				material: material,
			}
		}
		return nil
	}))
}
Example #5
0
func init() {
	world.Register("wall", world.Visible((*Wall)(nil)))
	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		if s == "wall" {
			return &Wall{
				material: material,
			}
		}
		return nil
	}))
}
Example #6
0
func init() {
	world.Register("hero", HeroLike((*Hero)(nil)))

	world.RegisterSpawnFunc(func(s string) world.Visible {
		for i := range raceInfo {
			r := Race(i)
			if r.Name() == s {
				return GenerateHeroRace(rand.New(rand.NewSource(rand.Int63())), r)
			}
		}
		return nil
	})
}
Example #7
0
func init() {
	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		if wood, stone, metal := material.Get(); len(wood) == 0 || len(stone) != 0 || len(metal) != 0 {
			return nil
		}
		switch s {
		case "tree":
			return &Tree{material: material}
		case "logs":
			return &Logs{material: material}
		}
		return nil
	}))
}
Example #8
0
func init() {
	world.Register("ingot", world.Visible((*Ingot)(nil)))

	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		wood, stone, metal := material.Get()
		if len(wood) != 0 || len(stone) != 0 || len(metal) == 0 {
			return nil
		}
		if s == "ingot" {
			return &Ingot{
				material: material,
			}
		}
		return nil
	}))
}
Example #9
0
func init() {
	world.Register("equip", world.Visible((*Equip)(nil)))

	world.RegisterSpawnFunc(material.WrapSpawnFunc(func(mat *material.Material, s string) world.Visible {
		wood, stone, metal := mat.Get()
		for t := range equippables {
			for i, e := range equippables[t] {
				if e.name == s {
					haveWood := false
					haveStone := false
					haveMetal := false
					for _, c := range e.colors {
						if c == woodColor {
							haveWood = true
						}
						if c == stoneColor {
							haveStone = true
						}
						if c == metalColor {
							haveMetal = true
						}
					}
					if !haveWood && len(wood) != 0 {
						continue
					}
					if !haveStone && len(stone) != 0 {
						continue
					}
					if !haveMetal && len(metal) != 0 {
						continue
					}
					return &Equip{
						slot:      EquipSlot(t),
						kind:      uint64(i),
						materials: []*material.Material{mat},
					}
				}
			}
		}
		return nil
	}))
}
Example #10
0
func init() {
	world.Register("critter", world.Combat((*Critter)(nil)))

	world.RegisterSpawnFunc(func(s string) world.Visible {
		living, s := world.SpawnModules(s)

		for t := CritterType(0); t < critterTypeCount; t++ {
			if s == t.Name() {
				return &Critter{
					CombatObject: world.CombatObject{
						LivingObject: living,
					},
					kind:   t,
					colors: t.GenerateColors(),
				}
			}
		}
		return nil
	})
}