From 6353bd7ce3341e87d69e3f1fe98e4a1c376a583f Mon Sep 17 00:00:00 2001 From: "anton.gurov" Date: Wed, 13 Nov 2019 10:58:30 +0300 Subject: [PATCH 1/3] prefab changes --- Makefile | 9 +++++--- config.json | 2 +- engine/gamemap/prefab.go | 47 ++++++++++++++++++++-------------------- go.mod | 2 +- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 750ecc1..55f67f6 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,8 @@ all: build test build: distclean build.deps build.game -# build.game: build.game.linux64 build.game.win64 build.game.mac -build.game: build.game.linux64 build.game.win64 +build.game: build.game.linux64 build.game.win64 build.game.mac +# build.game: build.game.linux64 build.game.win64 build.deps: GIT_SSL_NO_VERIFY=true $(GO) mod vendor @@ -45,11 +45,14 @@ build.game.win64: /usr/bin/x86_64-w64-mingw32-strip $(DISTFOLDER)/game.exe && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* + + +# OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && build.game.mac: cp $(CWD)/lib/mac/libBearLibTerminal.dylib $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ cp -r $(CWD)/assets $(DISTFOLDER) && \ - OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && \ + OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=clang CXX=clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && \ strip $(DISTFOLDER)/game.exe && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* diff --git a/config.json b/config.json index 82c7864..35b4a64 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "version": "v0.0.1.5-1-gbecf7ea", + "version": "v0.0.1.6", "title": "Alchemyst", "sizeX": 100, "sizeY": 47, diff --git a/engine/gamemap/prefab.go b/engine/gamemap/prefab.go index 8d9141e..6db71f1 100644 --- a/engine/gamemap/prefab.go +++ b/engine/gamemap/prefab.go @@ -30,7 +30,7 @@ type PrefabRecord struct { func LoadPrefabFile(filename string) (*PrefabFile, error) { data, err := ioutil.ReadFile(filename) - if err!= nil { + if err != nil { return nil, err } instance := &PrefabFile{} @@ -53,7 +53,7 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room { rooms := make([]Room, 0) file, err := LoadPrefabFile("./assets/prefabs/test.json") - if err !=nil { + if err != nil { panic(err) } @@ -63,23 +63,23 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room { currentMobsLegend := file.DefaultMobsLegend currentItemLegend := file.DefaultItemLegend - for k,v := range rawPrefab.TileLegend { + for k, v := range rawPrefab.TileLegend { currentTileLegend[k] = v } - for k,v := range rawPrefab.MobsLegend { + for k, v := range rawPrefab.MobsLegend { currentMobsLegend[k] = v } - for k,v := range rawPrefab.ItemLegend { + for k, v := range rawPrefab.ItemLegend { currentItemLegend[k] = v } room := Room{ - Rect:types.Rect{0, 0, rawPrefab.Size.X, rawPrefab.Size.Y}, - Center: types.Coords{rawPrefab.Size.X / 2, rawPrefab.Size.Y / 2}, //fixme - Geometry: make([]func()*Tile, rawPrefab.Size.X*rawPrefab.Size.Y), - Mobs: make([]mob.Mob, rawPrefab.Size.X*rawPrefab.Size.Y), - Items: make([]items.Carried, rawPrefab.Size.X*rawPrefab.Size.Y), - Connectors: make([]types.Coords, 0), + Rect: types.Rect{0, 0, rawPrefab.Size.X, rawPrefab.Size.Y}, + Center: types.Coords{rawPrefab.Size.X / 2, rawPrefab.Size.Y / 2}, //fixme + Geometry: make([]func() *Tile, rawPrefab.Size.X*rawPrefab.Size.Y), + Mobs: make([]mob.Mob, rawPrefab.Size.X*rawPrefab.Size.Y), + Items: make([]items.Carried, rawPrefab.Size.X*rawPrefab.Size.Y), + Connectors: make([]types.Coords, 0), } //make geometry var f func() *Tile @@ -89,7 +89,7 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room { if len(str) != room.W { continue; } - for i:=0; i < room.W; i++ { + for i := 0; i < room.W; i++ { ok := false shortName := currentTileLegend[string(str[i])] if shortName == "" { @@ -100,14 +100,15 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room { } if shortName == "connector" { f = NewFloor - room.Connectors = append(room.Connectors, types.Coords{i,j}) + room.Connectors = append(room.Connectors, types.Coords{i, j}) } else { f, ok = TileTypeMap[shortName] + + if (!ok) { + pfbl.ctx.Logger().Warn().Msgf("Unknown tile: %s", shortName) + } } - if (!ok) { - pfbl.ctx.Logger().Warn().Msgf("Unknown tile: %s", shortName) - } - room.Geometry[i+ j*room.W] = f + room.Geometry[i+j*room.W] = f } } //add room to list @@ -116,10 +117,10 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room { return rooms } -var TileTypeMap = map[string]func()*Tile{ - "wall": NewWall, - "floor": NewFloor, +var TileTypeMap = map[string]func() *Tile{ + "wall": NewWall, + "floor": NewFloor, "decorated_wall": NewDecoratedWall, - "water": NewWaterTile, - "deep_water": NewDeepWaterTile, -} \ No newline at end of file + "water": NewWaterTile, + "deep_water": NewDeepWaterTile, +} diff --git a/go.mod b/go.mod index fc2333a..bf01685 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/gammazero/deque v0.0.0-20190521012701-46e4ffb7a622 - github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a + github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect github.com/rs/zerolog v1.15.0 lab.zaar.be/thefish/bearlibterminal v0.0.0-20191018101635-dd37bbc90d77 ) From d5a853df0ea1be5ef293db76b0d9014b133fe438 Mon Sep 17 00:00:00 2001 From: "anton.gurov" Date: Wed, 13 Nov 2019 15:59:09 +0300 Subject: [PATCH 2/3] update settings --- config.json | 2 +- engine/screens/devmenu.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 35b4a64..597bb95 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,6 @@ "sizeY": 47, "fpsLimit": 60, "font": "./assets/fonts/ttf/LiberationMono-Bold.ttf", - "fontSize": "9x14", + "fontSize": "8x14", "verbosity": "debug" } \ No newline at end of file diff --git a/engine/screens/devmenu.go b/engine/screens/devmenu.go index fcb24f7..edbcca8 100644 --- a/engine/screens/devmenu.go +++ b/engine/screens/devmenu.go @@ -101,7 +101,7 @@ func (devm *DevmenuScreen) Render() { menuLayer.WithColor(devm.fgColor).PrintInside( devm.Rect, strings.Join([]string{ - "Dev Menu:", + "Действия для разработчика:", "[color=green]v[/color] - set all tiles visible", "[color=green]i[/color] - set all tiles invisible", fmt.Sprintf("[color=green]p[/color] - toggle passwall: %v", From 999f48afe9b2d15f17ee29470680a5fb68a7158b Mon Sep 17 00:00:00 2001 From: "anton.gurov" Date: Wed, 13 Nov 2019 18:55:11 +0300 Subject: [PATCH 3/3] phase shifts, itemize --- assets/logo2.txt | 17 +++++++ cmd/game/main.go | 16 +++---- engine/ecs/component.go | 5 ++ engine/gamemap/prefab.go | 2 +- engine/items/ammo.go | 14 ++++++ engine/items/armor.go | 11 +++++ engine/items/arms.go | 14 ++++++ engine/items/carried.go | 20 +++++++- engine/items/itemprops/damage.go | 7 +++ engine/items/ranged.go | 11 +++++ engine/items/useable.go | 11 ++++- engine/items/wearable.go | 16 +++++++ engine/matertals/properties.go | 82 ++++++++++++++++++++++++++++++++ util/kruskals/algorithm.go | 2 +- 14 files changed, 213 insertions(+), 15 deletions(-) create mode 100644 assets/logo2.txt create mode 100644 engine/items/ammo.go create mode 100644 engine/items/armor.go create mode 100644 engine/items/arms.go create mode 100644 engine/items/itemprops/damage.go create mode 100644 engine/items/ranged.go create mode 100644 engine/items/wearable.go create mode 100644 engine/matertals/properties.go diff --git a/assets/logo2.txt b/assets/logo2.txt new file mode 100644 index 0000000..bc10a2c --- /dev/null +++ b/assets/logo2.txt @@ -0,0 +1,17 @@ + + ^^:^|+ ! ,` ':: + 'Uz 3F` |/ `cz\RR + U| ye` /l zy- + gc ff ^v ik` : + l| :F c -!!: + + + .- ,` `, '' : '' -. `' `` `-'!! + '.f^ sw! !u|,,\%N; ipf tdD -|l!":aXr ',|| lf u%' tOc ru;.,C0q ,r` iXD! !t + `uqE' !w: -!w ul ,Uw !e# rye- ?ez ';3= !B? /d> :az !v0| ,a 'kw + `vv=ee i%! !w' ,o9i?zFsfU# !39z|?|// ^OWws` taq? -dgc `/f `t#%+ 'oe + `r3 ueo s%! 'qQ` ,pe >kW lgw |OXX|-ue/9> zgO! =e' ^DQw. 'Fe + :Cr!::|Ec cq! UQs 'Da >%W !QB` vR- cC' ^e> 3EW! -eQ%: 'qU + :a` `ON; /q| `#@e .yd ,ge |BQ sBp, ,y |D +k| :kd EB= !q: 'pq + ^w" ,qd :dE+!!!!!sw eQqs|zU/ #Q^ ,Q@z ,qU/::i| Fg zN/ !Qg E#pz>zw' R@C + `''''''` ` , , diff --git a/cmd/game/main.go b/cmd/game/main.go index 83bfd43..65c4e8f 100644 --- a/cmd/game/main.go +++ b/cmd/game/main.go @@ -136,16 +136,12 @@ func main() { SetBgColor("#ef305c70"). SetFgColor("white"). SetItems([]interface{}{ - "hjklyubn, NumPad 12346789, arrow keys - move", - "s or . - pass turn", - "g or , - pick up item", - "i - inventory", - "? - this screen", - "Ctrl+q - exit", - "f or F - fire or throw weapon", - "z or Z - cast a spell", - "p - pray", - "Ctrl+p - message log", + `"Fisheye" crafty shaded glasses`, + "Xecutor's glowing visor", + "Kitschy goggles of many pathways", + "Ring of inexistence", + "Orb of omniscience", + "Wand of amnesia", }).MakeList(), ) diff --git a/engine/ecs/component.go b/engine/ecs/component.go index ca6f6bb..77c5ab3 100644 --- a/engine/ecs/component.go +++ b/engine/ecs/component.go @@ -8,6 +8,11 @@ const MobComponent = "mob" const MoveableComponent = "movable" const CarriedComponent = "carried" const UsableComponent = "usable" +const WearableComponent = "usable" +const ArmsComponent = "arms" +const RangedComponent = "ranged" +const AmmoComponent = "ammo" +const ArmorComponent = "armor" type Component interface { Type() string diff --git a/engine/gamemap/prefab.go b/engine/gamemap/prefab.go index 063581d..e70462b 100644 --- a/engine/gamemap/prefab.go +++ b/engine/gamemap/prefab.go @@ -21,7 +21,7 @@ type PrefabRecord struct { Size struct { X int `json:"x"` Y int `json:"y"` - } `json:"Size"` + } `json:"Bulk"` TileLegend map[string]string `json:"tile_legend"` MobsLegend map[string]string `json:"mobs_legend"` ItemLegend map[string]string `json:"item_legend"` diff --git a/engine/items/ammo.go b/engine/items/ammo.go new file mode 100644 index 0000000..d534853 --- /dev/null +++ b/engine/items/ammo.go @@ -0,0 +1,14 @@ +package items + +import ( + "lab.zaar.be/thefish/alchemyst-go/engine/ecs" + "lab.zaar.be/thefish/alchemyst-go/engine/items/itemprops" +) + +type Ammo struct { + itemprops.DamageProfile +} + +func (a *Ammo) Type() string { + return ecs.AmmoComponent +} \ No newline at end of file diff --git a/engine/items/armor.go b/engine/items/armor.go new file mode 100644 index 0000000..9864d8e --- /dev/null +++ b/engine/items/armor.go @@ -0,0 +1,11 @@ +package items + +import "lab.zaar.be/thefish/alchemyst-go/engine/ecs" + +type Armor struct { + DefenceProfile struct{} +} + +func (a *Armor) Type() string { + return ecs.ArmorComponent +} diff --git a/engine/items/arms.go b/engine/items/arms.go new file mode 100644 index 0000000..6ec8e4a --- /dev/null +++ b/engine/items/arms.go @@ -0,0 +1,14 @@ +package items + +import ( + "lab.zaar.be/thefish/alchemyst-go/engine/ecs" + "lab.zaar.be/thefish/alchemyst-go/engine/items/itemprops" +) + +type Arms struct { + itemprops.DamageProfile +} + +func (a Arms) Type() string { + return ecs.ArmsComponent +} diff --git a/engine/items/carried.go b/engine/items/carried.go index ef4ecad..95b21e1 100644 --- a/engine/items/carried.go +++ b/engine/items/carried.go @@ -2,8 +2,26 @@ package items import "lab.zaar.be/thefish/alchemyst-go/engine/ecs" -type Carried struct {} +type CarriedFace interface { + Drop() + Pickup() +} + +type Carried struct { + Mass int //масса в граммах + Bulk int //внешний размер, см3 +} func (c *Carried) Type() string { return ecs.CarriedComponent } + +func (c *Carried) Pickup() {} +func (c *Carried) Drop() {} + +func (c *Carried) GetMass() int { + return c.Mass +} +func (c *Carried) GetBulk() int { + return c.Bulk +} \ No newline at end of file diff --git a/engine/items/itemprops/damage.go b/engine/items/itemprops/damage.go new file mode 100644 index 0000000..82d8cc1 --- /dev/null +++ b/engine/items/itemprops/damage.go @@ -0,0 +1,7 @@ +package itemprops + +type DamageProfile struct { + Pierce int + Bash int + Cleave int +} diff --git a/engine/items/ranged.go b/engine/items/ranged.go new file mode 100644 index 0000000..a462430 --- /dev/null +++ b/engine/items/ranged.go @@ -0,0 +1,11 @@ +package items + +import "lab.zaar.be/thefish/alchemyst-go/engine/ecs" + +type Ranged struct { + RangeProfile struct{} //это зависимость дальности-скорости от характеристик и атрибутов +} + +func (r *Ranged) Type() string { + return ecs.RangedComponent +} diff --git a/engine/items/useable.go b/engine/items/useable.go index dd8efaf..922d354 100644 --- a/engine/items/useable.go +++ b/engine/items/useable.go @@ -2,9 +2,16 @@ package items import "lab.zaar.be/thefish/alchemyst-go/engine/ecs" -type Useable struct {} +type UsableFace interface { + Use() +} + +type Usable struct {} -func (u *Useable) Type() string { +func (u *Usable) Type() string { return ecs.UsableComponent +} + +func (u *Usable) Use() { } \ No newline at end of file diff --git a/engine/items/wearable.go b/engine/items/wearable.go new file mode 100644 index 0000000..0dd00f7 --- /dev/null +++ b/engine/items/wearable.go @@ -0,0 +1,16 @@ +package items + +import "lab.zaar.be/thefish/alchemyst-go/engine/ecs" + +type WearableFace interface { + Wear() + Takeoff() +} + +type Wearable struct { + Bodypart int //куда собстно одевать +} + +func (w *Wearable) Type() string { + return ecs.WearableComponent +} diff --git a/engine/matertals/properties.go b/engine/matertals/properties.go new file mode 100644 index 0000000..e8604bc --- /dev/null +++ b/engine/matertals/properties.go @@ -0,0 +1,82 @@ +package matertals + +import "github.com/rs/zerolog/log" + +type MaterialProperties struct { + Density float64 //Плотность (кг / м3) + Tougnness float64 //Ударная вязкость, мера скорости поглощения энергии без деформаций, джоули на квадратный метр в секунду + Brittleness float64 //Хрупкость - обратная пластичности (в основном за счет внешних эффектов), джоули на квадртаный метр, после которых раскол + MeltingPoint float64 //точка перехода из твердого в жидкое, градусы Цельсия при нормальном давлении + BoilingPoint float64 //точка кипения - из жидкого в газ, градусы Цельсия при нормальном давлении + Conductivity bool //проводимость эл. тока +} + +//агрегатное состояние +type MatterState int + +const ( + Solid MatterState = iota //кристаллическая решетка + Liquid + Gas + Plasma + + Glass //нет кристаллической решетки, аморфный +) + +var transitions = map[MatterState][]MatterState{ + Solid: {Liquid, Gas}, + Liquid: {Solid, Gas, Glass}, + Gas: {Solid, Plasma}, + Plasma: {Gas}, + + Glass: {Liquid}, + +} + +func (ms MatterState) Change(from MatterState, to MatterState) bool { + if from == to { + return true + } + + _, ok := transitions[from] + + if ok { + newStateFound := func(lst []MatterState, to MatterState) bool { + for _, b := range lst { + if b == to { + return true + } + } + return false + }(transitions[from], to) + if !newStateFound { + log.Warn().Msgf("Transition %s -> %s is impossible", from, to) + return false + } + // check temperatures/conditions, see template + /* + Solid -> Gas Sublimation + Solid -> Liquid Melting + + Liquid -> Gas Boiling + Liquid -> Solid Freezing + + Gas -> Solid Deposition + Gas -> Liquid Condensation + + Gas -> Plasma Ionization + Plasma -> Gas Recombination + */ + } + + //При фазовом переходе первого рода скачкообразно изменяются самые главные, первичные экстенсивные параметры: + // удельный объём, + // количество запасённой внутренней энергии, + // концентрация компонентов и т. п. + // + // Фазовые переходы второго рода происходят в тех случаях, когда меняется симметрия строения вещества + // (симметрия может полностью исчезнуть или понизиться). + + return true + +} \ No newline at end of file diff --git a/util/kruskals/algorithm.go b/util/kruskals/algorithm.go index caf3c3a..679d26d 100644 --- a/util/kruskals/algorithm.go +++ b/util/kruskals/algorithm.go @@ -12,7 +12,7 @@ type WeightedEdge interface { From() int // To returns the integer identifier of the second vertex. To() int - // Weight returns the integer identifier of the weight/cost. + // Mass returns the integer identifier of the weight/cost. Weight() int }