Skip to content

Commit

Permalink
Move attribute to storage
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Smart <[email protected]>
  • Loading branch information
mcred committed Feb 20, 2020
1 parent 61ded03 commit 6cb1c84
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 107 deletions.
16 changes: 8 additions & 8 deletions internal/app/characters/Albert.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Albert() Character { //TODO MAP
return Character{
ID: 05,
Name: "Albert",
XP: common.Attribute{0x608,4,true},
HP: common.Attribute{0x610,2,true},
Weapon: common.Attribute{0x61C,1,false},
Helmet: common.Attribute{0x61D,1,false},
Chest: common.Attribute{0x61E,1,false},
Boots: common.Attribute{0x61F,1,false},
Accessory: common.Attribute{0x620,1,false},
XP: storage.Attribute{0x608,4,true},
HP: storage.Attribute{0x610,2,true},
Weapon: storage.Attribute{0x61C,1,false},
Helmet: storage.Attribute{0x61D,1,false},
Chest: storage.Attribute{0x61E,1,false},
Boots: storage.Attribute{0x61F,1,false},
Accessory: storage.Attribute{0x620,1,false},
}
}
16 changes: 8 additions & 8 deletions internal/app/characters/Character.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

type Character struct {
ID int
Name string
XP common.Attribute
HP common.Attribute
Weapon common.Attribute
Helmet common.Attribute
Chest common.Attribute
Boots common.Attribute
Accessory common.Attribute
XP storage.Attribute
HP storage.Attribute
Weapon storage.Attribute
Helmet storage.Attribute
Chest storage.Attribute
Boots storage.Attribute
Accessory storage.Attribute
}

func GetCharacters() []Character {
Expand Down
16 changes: 8 additions & 8 deletions internal/app/characters/Dart.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Dart() Character {
return Character{
ID: 0,
Name: "Dart",
XP: common.Attribute{0x52C,4,true},
HP: common.Attribute{0x534,2,true},
Weapon: common.Attribute{0x540,1,false},
Helmet: common.Attribute{0x541,1,false},
Chest: common.Attribute{0x542,1,false},
Boots: common.Attribute{0x543,1,false},
Accessory: common.Attribute{0x544,1,false},
XP: storage.Attribute{0x52C,4,true},
HP: storage.Attribute{0x534,2,true},
Weapon: storage.Attribute{0x540,1,false},
Helmet: storage.Attribute{0x541,1,false},
Chest: storage.Attribute{0x542,1,false},
Boots: storage.Attribute{0x543,1,false},
Accessory: storage.Attribute{0x544,1,false},
}
}
16 changes: 8 additions & 8 deletions internal/app/characters/Haschel.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Haschel() Character { //TODO MAP
return Character{
ID: 04,
Name: "Haschel",
XP: common.Attribute{0x5DC,4,true},
HP: common.Attribute{0x5E4,2,true},
Weapon: common.Attribute{0x5F0,1,false},
Helmet: common.Attribute{0x5F1,1,false},
Chest: common.Attribute{0x5F2,1,false},
Boots: common.Attribute{0x5F3,1,false},
Accessory: common.Attribute{0x5F4,1,false},
XP: storage.Attribute{0x5DC,4,true},
HP: storage.Attribute{0x5E4,2,true},
Weapon: storage.Attribute{0x5F0,1,false},
Helmet: storage.Attribute{0x5F1,1,false},
Chest: storage.Attribute{0x5F2,1,false},
Boots: storage.Attribute{0x5F3,1,false},
Accessory: storage.Attribute{0x5F4,1,false},
}
}
16 changes: 8 additions & 8 deletions internal/app/characters/Kongol.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Kongol() Character { //TODO map
return Character{
ID: 07,
Name: "Kongol",
XP: common.Attribute{0x660,4,true},
HP: common.Attribute{0x668,2,true},
Weapon: common.Attribute{0x674,1,false},
Helmet: common.Attribute{0x675,1,false},
Chest: common.Attribute{0x676,1,false},
Boots: common.Attribute{0x677,1,false},
Accessory: common.Attribute{0x678,1,false},
XP: storage.Attribute{0x660,4,true},
HP: storage.Attribute{0x668,2,true},
Weapon: storage.Attribute{0x674,1,false},
Helmet: storage.Attribute{0x675,1,false},
Chest: storage.Attribute{0x676,1,false},
Boots: storage.Attribute{0x677,1,false},
Accessory: storage.Attribute{0x678,1,false},
}
}
16 changes: 8 additions & 8 deletions internal/app/characters/Lavitz.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Lavitz() Character {
return Character{
ID: 1,
Name: "Lavitz",
XP: common.Attribute{0x558,4,true},
HP: common.Attribute{0x560,2,true},
Weapon: common.Attribute{0x56C,1,false},
Helmet: common.Attribute{0x56D,1,false},
Chest: common.Attribute{0x56E,1,false},
Boots: common.Attribute{0x56F,1,false},
Accessory: common.Attribute{0x570,1,false},
XP: storage.Attribute{0x558,4,true},
HP: storage.Attribute{0x560,2,true},
Weapon: storage.Attribute{0x56C,1,false},
Helmet: storage.Attribute{0x56D,1,false},
Chest: storage.Attribute{0x56E,1,false},
Boots: storage.Attribute{0x56F,1,false},
Accessory: storage.Attribute{0x570,1,false},
}
}
16 changes: 8 additions & 8 deletions internal/app/characters/Meru.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Meru() Character { //TODO map
return Character{
ID: 06,
Name: "Meru",
XP: common.Attribute{0x634,4,true},
HP: common.Attribute{0x63C,2,true},
Weapon: common.Attribute{0x648,1,false},
Helmet: common.Attribute{0x649,1,false},
Chest: common.Attribute{0x64A,1,false},
Boots: common.Attribute{0x64B,1,false},
Accessory: common.Attribute{0x64C,1,false},
XP: storage.Attribute{0x634,4,true},
HP: storage.Attribute{0x63C,2,true},
Weapon: storage.Attribute{0x648,1,false},
Helmet: storage.Attribute{0x649,1,false},
Chest: storage.Attribute{0x64A,1,false},
Boots: storage.Attribute{0x64B,1,false},
Accessory: storage.Attribute{0x64C,1,false},
}
}
16 changes: 8 additions & 8 deletions internal/app/characters/Miranda.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Miranda() Character { //TODO Map
return Character{
ID: 8,
Name: "Miranda",
XP: common.Attribute{0x68C,4,true},
HP: common.Attribute{0x694,2,true},
Weapon: common.Attribute{0x6A0,1,false},
Helmet: common.Attribute{0x6A1,1,false},
Chest: common.Attribute{0x6A2,1,false},
Boots: common.Attribute{0x6A3,1,false},
Accessory: common.Attribute{0x6A4,1,false},
XP: storage.Attribute{0x68C,4,true},
HP: storage.Attribute{0x694,2,true},
Weapon: storage.Attribute{0x6A0,1,false},
Helmet: storage.Attribute{0x6A1,1,false},
Chest: storage.Attribute{0x6A2,1,false},
Boots: storage.Attribute{0x6A3,1,false},
Accessory: storage.Attribute{0x6A4,1,false},
}
}
20 changes: 10 additions & 10 deletions internal/app/characters/Rose.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Rose() Character {
return Character{
ID: 3,
Name: "Rose",
XP: common.Attribute{0x5B0,4,true},
HP: common.Attribute{0x5B8,2,true},
Weapon: common.Attribute{0x5C4,1,false},
Helmet: common.Attribute{0x5C5,1,false},
Chest: common.Attribute{0x5C6,1,false},
Boots: common.Attribute{0x5C7,1,false},
Accessory: common.Attribute{0x5C8,1,false},
ID: 3,
Name: "Rose",
XP: storage.Attribute{0x5B0,4,true},
HP: storage.Attribute{0x5B8,2,true},
Weapon: storage.Attribute{0x5C4,1,false},
Helmet: storage.Attribute{0x5C5,1,false},
Chest: storage.Attribute{0x5C6,1,false},
Boots: storage.Attribute{0x5C7,1,false},
Accessory: storage.Attribute{0x5C8,1,false},
}
}
20 changes: 10 additions & 10 deletions internal/app/characters/Shana.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package characters

import (
"LODeditor/internal/app/common"
"LODeditor/internal/app/storage"
)

func Shana() Character {
return Character{
ID: 2,
Name: "Shana",
XP: common.Attribute{0x584,4,true},
HP: common.Attribute{0x58C,2,true},
Weapon: common.Attribute{0x598,1,false},
Helmet: common.Attribute{0x599,1,false},
Chest: common.Attribute{0x59A,1,false},
Boots: common.Attribute{0x59B,1,false},
Accessory: common.Attribute{0x59C,1,false},
ID: 2,
Name: "Shana",
XP: storage.Attribute{0x584,4,true},
HP: storage.Attribute{0x58C,2,true},
Weapon: storage.Attribute{0x598,1,false},
Helmet: storage.Attribute{0x599,1,false},
Chest: storage.Attribute{0x59A,1,false},
Boots: storage.Attribute{0x59B,1,false},
Accessory: storage.Attribute{0x59C,1,false},
}
}
10 changes: 6 additions & 4 deletions internal/app/common/Collectibles.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package common

func Gold() Attribute {
return Attribute{0x294, 4, true}
import "LODeditor/internal/app/storage"

func Gold() storage.Attribute {
return storage.Attribute{0x294, 4, true}
}
func GoldDisplay() Attribute {
return Attribute{0x19C, 4, true}
func GoldDisplay() storage.Attribute {
return storage.Attribute{0x19C, 4, true}
}
26 changes: 14 additions & 12 deletions internal/app/common/Positions.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package common

func First() Attribute {
return Attribute{0x288,1,false}
import "LODeditor/internal/app/storage"

func First() storage.Attribute {
return storage.Attribute{0x288,1,false}
}
func FirstDisplay() Attribute {
return Attribute{0x188,1,false}
func FirstDisplay() storage.Attribute {
return storage.Attribute{0x188,1,false}
}

func Second() Attribute {
return Attribute{0x28C,1,false}
func Second() storage.Attribute {
return storage.Attribute{0x28C,1,false}
}
func SecondDisplay() Attribute {
return Attribute{0x18C,1,false}
func SecondDisplay() storage.Attribute {
return storage.Attribute{0x18C,1,false}
}

func Third() Attribute {
return Attribute{0x290,1,false}
func Third() storage.Attribute {
return storage.Attribute{0x290,1,false}
}
func ThirdDisplay() Attribute {
return Attribute{0x190,1,false}
func ThirdDisplay() storage.Attribute {
return storage.Attribute{0x190,1,false}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package common
package storage

type Attribute struct {
Location int
Expand Down
5 changes: 2 additions & 3 deletions internal/app/storage/Slot.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package storage

import (
"LODeditor/internal/app/common"
"encoding/binary"
)

Expand All @@ -10,7 +9,7 @@ type Slot struct {
Data []byte
}

func (s *Slot) GetValueByAttribute(a common.Attribute) int {
func (s *Slot) GetValueByAttribute(a Attribute) int {
b := s.Data[a.Location:(a.Location+a.Bytes)]
if a.Reversed {
switch a.Bytes {
Expand All @@ -33,7 +32,7 @@ func (s *Slot) GetValueByAttribute(a common.Attribute) int {
}
}

func (s *Slot) SetValueAtLocation(a common.Attribute, val int) {
func (s *Slot) SetValueAtLocation(a Attribute, val int) {
b := make([]byte, a.Bytes)
if a.Reversed {
switch a.Bytes {
Expand Down
6 changes: 3 additions & 3 deletions internal/app/ui/Form.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ var meru = characters.Meru()
var kongol = characters.Kongol()
var miranda = characters.Miranda()

func createCharSelect(i inventory.Inventory, a common.Attribute, s *storage.Slot) *widget.Select {
func createCharSelect(i inventory.Inventory, a storage.Attribute, s *storage.Slot) *widget.Select {
r := widget.NewSelect(i.GetVals(), func(v string) {
s.SetValueAtLocation(a, i.GetIDByVal(v))
})
r.SetSelected(i.GetValByID(s.GetValueByAttribute(a)))
return r
}

func createPosSelect(n []string, a common.Attribute, ad common.Attribute, s *storage.Slot) *widget.Select {
func createPosSelect(n []string, a storage.Attribute, ad storage.Attribute, s *storage.Slot) *widget.Select {
r := widget.NewSelect(n, func(v string) {
s.SetValueAtLocation(a, characters.GetIDByName(v))
s.SetValueAtLocation(ad, characters.GetIDByName(v))
Expand All @@ -40,7 +40,7 @@ func createPosSelect(n []string, a common.Attribute, ad common.Attribute, s *sto
return r
}

func createCharEntry(a common.Attribute, s *storage.Slot) *widget.Entry {
func createCharEntry(a storage.Attribute, s *storage.Slot) *widget.Entry {
e := widget.NewEntry()
e.SetPlaceHolder(strconv.Itoa(s.GetValueByAttribute(a)))
e.OnChanged = func(v string) {
Expand Down

0 comments on commit 6cb1c84

Please sign in to comment.