world

package
v0.0.0-...-7b575b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

This package manages the world Supported actions: handling the cities lists, generating new world, load database of cities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNumOfDestroyedCities

func GetNumOfDestroyedCities(listOfCities Cities) int64

This function counts and returns the number of destroyed cities

func PrintAllCities

func PrintAllCities(listOfCities Cities)

This function receives a slice of cities and prints them all,

Types

type Cities

type Cities []*City

func Generate

func Generate(numOfCities int64) Cities

This function receives the number of cities and generates a new world accordingly It returns a slice holding all the pointers to the cities

func Load

func Load(filepath string) (Cities, error)

This function receives a `filepath`, attempts to load the file then hands over the content to `parseText()` for further processing It returns the parsed data in form of a slice of pointers to all cities

type City

type City struct {
	// contains filtered or unexported fields
}

func (*City) Enter

func (c *City) Enter(invaderName string)

This function is called once the city is visited by an alien The invasion result can happen here

func (*City) GetEast

func (c *City) GetEast() *City

func (*City) GetInvaderNames

func (c *City) GetInvaderNames() []string

func (*City) GetName

func (c *City) GetName() string

func (*City) GetNorth

func (c *City) GetNorth() *City

func (*City) GetSouth

func (c *City) GetSouth() *City

func (*City) GetWest

func (c *City) GetWest() *City

func (*City) IsDestroyed

func (c *City) IsDestroyed() bool

func (*City) Leave

func (c *City) Leave(invaderName string)

This function is called once the city is left by an alien

func (*City) String

func (c *City) String() string

This function prepares the printable string of the available city (i.e. if not destroyed) in the same format of the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL