Commit 9412e7b0 authored by ceddral's avatar ceddral
Browse files

pieces: change encoding to distinguish specials

pennants, inns, cathedrals
parent 3fbcacbe
......@@ -45,6 +45,14 @@ const (
fTower FType = 't'
)
type FSpecial byte
const (
fPennant FSpecial = 'p'
fInn FSpecial = 'i'
fCathedral FSpecial = 'c'
)
type Field struct {
preRendered []byte
t FType
......@@ -57,6 +65,7 @@ type Field struct {
type Piece struct {
f [][][]Field // 'graphic' representation [rotation][row][col]
fieldIdToType map[byte]FType
fieldIdToSpecial map[byte][]FSpecial
copies int
}
......@@ -515,10 +524,13 @@ func readpieces(filename string) (pieces []Piece, err error) {
}
row = 0
curPiece.fieldIdToType = make(map[byte]FType)
curPiece.fieldIdToSpecial = make(map[byte][]FSpecial)
meta := strings.Split(s.Text(), " ")
curPiece.fieldIdToType['X'] = fFarm
for i, c := range []byte(meta[0]) {
curPiece.fieldIdToType[byte(i) + '0'] = FType(c)
id := byte(i) + '0'
curPiece.fieldIdToType[id] = FType(c)
curPiece.fieldIdToSpecial[id] = make([]FSpecial, 0)
}
curPiece.copies, err = strconv.Atoi(meta[1])
if err != nil {
......@@ -541,7 +553,16 @@ func readpieces(filename string) (pieces []Piece, err error) {
}
fields[x].preRendered = tg.RenderBlock(fg, typeBG[fields[x].t], fields[x].c, ^tg.TermUnderline, ^tg.TermBold)
} else {
fields[x].placeable = c != '_' && c != '*'
if c == '_' {
continue
}
id := fields[x].id
if c == id {
fields[x].placeable = true
continue
}
sm := curPiece.fieldIdToSpecial
sm[id] = append(sm[id], FSpecial(c))
}
}
rotation++
......
......@@ -11,17 +11,17 @@ bm 4
00100 + __1__00100 + __1__00100 + __1__00100 + __1__
00000 _____00000 _____00000 _0___00000 ___0_
r 1
00000* *____00000 _____00000 _____00000 *____*
00000* p____00000 _____00000 _____00000 *____p
00000 __0__00000 __0__00000 __0__00000 __0__
00000 _____00000* *____00000 *____*00000 _____
00000 _____00000* p____00000 *____p00000 _____
br 5
01110 __1__10000 _____00000 _____00001 _____
00000 ___0_11000 1_0__00000 _0___00011 __0_1
00000 _____10000 _____01110 __1__00001 _____
rbb 2
01110 __1__10002 * __*__02220 __2__20001 __0__
00000 *0___*11022 1___200000* *___022011 2___1
02220 __2__10002 __0__01110 __1__20001 * __*__
01110 __1__10002 * __p__02220 __2__20001 __0__
00000 *0___p11022 1___200000* p___022011 2___1
02220 __2__10002 __0__01110 __1__20001 * __p__
brb 1
01112 _____12221 __2__21110 __1__10001 __0__
00122 0___211111 1____22100 2___011111 ____1
......@@ -47,33 +47,33 @@ bwbrwbw 3
44X33--| _4__311X66--v--_1_6_33X44 |--3__4_66X11--^--_6_1_
55623 | 5_6__00455 | 0_4_532100 | _21_023332 __3_2
rb 2
00001* *____01111 _____11110 _____10000 *____*
00001* p____01111 _____11110 _____10000 *____p
00111 _0_1_00111 _0_1_11100 _1_0_11100 _1_0_
01111 _____00001* *____10000 *____*11110 _____
01111 _____00001* p____10000 *____p11110 _____
rb 3
00001 _____01111 _____11110 _____10000 _____
00111 _0_1_00111 _0_1_11100 _1_0_11100 _1_0_
01111 _____00001 _____10000 _____11110 _____
rbwb 2
00001* *___101233 | ____333210 | 3____10000 *1___*
00001* p___101233 | ____333210 | 3____10000 *1___p
00222 .--_0_2_00222 '--_0_2_22200--' _2_0_22200--. _2_0_
01233 | ____300001* *___110000 *1___*33210 | 3____
01233 | ____300001* p___110000 *1___p33210 | 3____
rbwb 3
00001 ____101233 | ____333210 | 3____10000 1____
00222 .--_0_2_00222 '--_0_2_22200--' _2_0_22200--. _2_0_
01233 | ____300001 ____110000 1____33210 | 3____
rb 1
00000* *__0_00001 _0___01110 __1__10000 *____*
00000* p__0_00001 _0___01110 __1__10000 *____p
00000 _____00011 ____100000 _____11000 1____
01110 __1__00001* *____00000 *_0__*10000 ___0_
01110 __1__00001* p____00000 *_0__p10000 ___0_
rb 3
00000 ___0_00001 _0___01110 __1__10000 _____
00000 _____00011 ____100000 _____11000 1____
01110 __1__00001 _____00000 _0___10000 ___0_
rbwb 2
00000* *__0_00003 _0__303210 | _321_10000 *1___*
00000* p__0_00003 _0__303210 | _321_10000 *1___p
00000 _____00022 --____200000 _____22000-- 2____
01230 | _123_00001* *___100000 *_0__*30000 3__0_
01230 | _123_00001* p___100000 *_0__p30000 3__0_
rbwb 1
00000 ___0_00003 _0__303210 | _321_10000 1____
00000 _____00022 --____200000 _____22000-- 2____
......
Supports Markdown
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