Add tabletop components 486-500 and ten game icons
Fifteen pieces of a games night: Dice, DiceTray, PlayingCard, CardHand, Deck, Chessboard, GoBoard, MahjongTile, Domino, Roulette, CoinFlip, BingoCard, TicTacToe, ScoreTrack and Meeple. Component number 500 is a meeple, which seems right. Dice tumble, coins turn and wheels spin on a cue, a frame at a time, and land at once under Reduce Motion. Hands lift the card you point at and play the one drawn on top; pieces and stones pick the lighter of Lit and Ink for White, so they read in every palette; the computer plays a fair O; FREE is a star in every language. New 12x12 icons: Spade, Club, Diamond, Meeple, King, Queen, Rook, Bishop, Knight and Pawn.
This commit is contained in:
32 files changed
+2781
-1
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package tabletop_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/data"
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/tabletop"
|
||||
)
|
||||
|
||||
func TestChessHoldsAreLoggedAndReported(t *testing.T) {
|
||||
var board [64]tabletop.Piece
|
||||
board[0] = tabletop.Piece{Kind: tabletop.Rook}
|
||||
held := []int{}
|
||||
log := logged(func() {
|
||||
tt := view(600, 400, newWorld(), func(c *ui.Context) {
|
||||
if r := tabletop.Chessboard(c, "B", &board, tabletop.ChessboardOptions{}); r.Changed {
|
||||
held = append(held, r.Held)
|
||||
}
|
||||
})
|
||||
cell(t, tt, "CHESSBOARD", 8, 16, 0)
|
||||
cell(t, tt, "CHESSBOARD", 8, 16, 0)
|
||||
// A move is a move, not a hold put down.
|
||||
cell(t, tt, "CHESSBOARD", 8, 16, 0)
|
||||
cell(t, tt, "CHESSBOARD", 8, 16, 8)
|
||||
})
|
||||
if len(held) != 3 || held[0] != 0 || held[1] != -1 || held[2] != 0 || strings.Count(log, "chess hold") != 3 {
|
||||
t.Fatalf("holds %v; log:\n%s", held, log)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMeepleSlotIsTheItemSlot(t *testing.T) {
|
||||
got := view(200, 200, newWorld(), func(c *ui.Context) {
|
||||
tabletop.Meeple(c, "M", tabletop.MeepleOptions{Empty: true})
|
||||
}).Image().Pix
|
||||
want := view(200, 200, newWorld(), func(c *ui.Context) {
|
||||
k := pixel.K(c)
|
||||
ui.Box(c).Size(k.D(data.SlotSize), k.D(data.SlotSize)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
data.DrawSlot(k.Canvas(p, r), 0, 0, data.Item{}, data.ItemSlotOptions{})
|
||||
})
|
||||
}).Image().Pix
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Fatal("an empty meeple slot is not data's item slot")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user