mirror of
https://github.com/Team254/cheesy-arena-lite.git
synced 2026-03-09 13:46:44 -04:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4bbf26b31 | ||
|
|
02cb9e4e41 | ||
|
|
e8c7d1103b | ||
|
|
5ee07ee33f |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.20.x
|
||||
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -7,7 +7,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.18.x
|
||||
go-version: 1.20.x
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v2
|
||||
- name: Build
|
||||
@@ -15,4 +15,4 @@ jobs:
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
- name: Check formatting
|
||||
run: go fmt ./...
|
||||
run: test -z "$(go fmt ./...)"
|
||||
|
||||
@@ -34,15 +34,15 @@ var doubleEliminationBracketMatchupTemplates = []matchupTemplate{
|
||||
matchupKey: newMatchupKey(1, 3),
|
||||
displayName: "3",
|
||||
NumWinsToAdvance: 1,
|
||||
redAllianceSource: allianceSource{allianceId: 3},
|
||||
blueAllianceSource: allianceSource{allianceId: 6},
|
||||
redAllianceSource: allianceSource{allianceId: 2},
|
||||
blueAllianceSource: allianceSource{allianceId: 7},
|
||||
},
|
||||
{
|
||||
matchupKey: newMatchupKey(1, 4),
|
||||
displayName: "4",
|
||||
NumWinsToAdvance: 1,
|
||||
redAllianceSource: allianceSource{allianceId: 2},
|
||||
blueAllianceSource: allianceSource{allianceId: 7},
|
||||
redAllianceSource: allianceSource{allianceId: 3},
|
||||
blueAllianceSource: allianceSource{allianceId: 6},
|
||||
},
|
||||
{
|
||||
matchupKey: newMatchupKey(2, 1),
|
||||
@@ -90,28 +90,28 @@ var doubleEliminationBracketMatchupTemplates = []matchupTemplate{
|
||||
matchupKey: newMatchupKey(4, 1),
|
||||
displayName: "11",
|
||||
NumWinsToAdvance: 1,
|
||||
redAllianceSource: newWinnerAllianceSource(3, 2),
|
||||
blueAllianceSource: newWinnerAllianceSource(3, 1),
|
||||
redAllianceSource: newWinnerAllianceSource(2, 3),
|
||||
blueAllianceSource: newWinnerAllianceSource(2, 4),
|
||||
},
|
||||
{
|
||||
matchupKey: newMatchupKey(4, 2),
|
||||
displayName: "12",
|
||||
NumWinsToAdvance: 1,
|
||||
redAllianceSource: newWinnerAllianceSource(2, 3),
|
||||
blueAllianceSource: newWinnerAllianceSource(2, 4),
|
||||
redAllianceSource: newWinnerAllianceSource(3, 2),
|
||||
blueAllianceSource: newWinnerAllianceSource(3, 1),
|
||||
},
|
||||
{
|
||||
matchupKey: newMatchupKey(5, 1),
|
||||
displayName: "13",
|
||||
NumWinsToAdvance: 1,
|
||||
redAllianceSource: newLoserAllianceSource(4, 2),
|
||||
blueAllianceSource: newWinnerAllianceSource(4, 1),
|
||||
redAllianceSource: newLoserAllianceSource(4, 1),
|
||||
blueAllianceSource: newWinnerAllianceSource(4, 2),
|
||||
},
|
||||
{
|
||||
matchupKey: newMatchupKey(6, 1),
|
||||
displayName: "F",
|
||||
NumWinsToAdvance: 2,
|
||||
redAllianceSource: newWinnerAllianceSource(4, 2),
|
||||
redAllianceSource: newWinnerAllianceSource(4, 1),
|
||||
blueAllianceSource: newWinnerAllianceSource(5, 1),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ func TestDoubleEliminationInitial(t *testing.T) {
|
||||
if assert.Equal(t, 4, len(matches)) {
|
||||
assertMatch(t, matches[0], "1", 1, 8)
|
||||
assertMatch(t, matches[1], "2", 4, 5)
|
||||
assertMatch(t, matches[2], "3", 3, 6)
|
||||
assertMatch(t, matches[3], "4", 2, 7)
|
||||
assertMatch(t, matches[2], "3", 2, 7)
|
||||
assertMatch(t, matches[3], "4", 3, 6)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,21 +65,21 @@ func TestDoubleEliminationProgression(t *testing.T) {
|
||||
assertMatch(t, matches[5], "7", 8, 4)
|
||||
}
|
||||
|
||||
scoreMatch(database, "3", game.RedWonMatch)
|
||||
scoreMatch(database, "3", game.BlueWonMatch)
|
||||
assert.Nil(t, bracket.Update(database, &dummyStartTime))
|
||||
matches, err = database.GetMatchesByType("elimination")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 6, len(matches))
|
||||
|
||||
scoreMatch(database, "4", game.BlueWonMatch)
|
||||
scoreMatch(database, "4", game.RedWonMatch)
|
||||
assert.Nil(t, bracket.Update(database, &dummyStartTime))
|
||||
matches, err = database.GetMatchesByType("elimination")
|
||||
assert.Nil(t, err)
|
||||
if assert.Equal(t, 8, len(matches)) {
|
||||
assertMatch(t, matches[4], "5", 1, 5)
|
||||
assertMatch(t, matches[5], "6", 6, 2)
|
||||
assertMatch(t, matches[5], "6", 2, 6)
|
||||
assertMatch(t, matches[6], "7", 8, 4)
|
||||
assertMatch(t, matches[7], "8", 3, 7)
|
||||
assertMatch(t, matches[7], "8", 7, 3)
|
||||
}
|
||||
|
||||
scoreMatch(database, "5", game.BlueWonMatch)
|
||||
@@ -88,7 +88,7 @@ func TestDoubleEliminationProgression(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 8, len(matches))
|
||||
|
||||
scoreMatch(database, "6", game.BlueWonMatch)
|
||||
scoreMatch(database, "6", game.RedWonMatch)
|
||||
assert.Nil(t, bracket.Update(database, &dummyStartTime))
|
||||
matches, err = database.GetMatchesByType("elimination")
|
||||
assert.Nil(t, err)
|
||||
@@ -102,13 +102,13 @@ func TestDoubleEliminationProgression(t *testing.T) {
|
||||
assertMatch(t, matches[8], "9", 8, 2)
|
||||
}
|
||||
|
||||
scoreMatch(database, "8", game.RedWonMatch)
|
||||
scoreMatch(database, "8", game.BlueWonMatch)
|
||||
assert.Nil(t, bracket.Update(database, &dummyStartTime))
|
||||
matches, err = database.GetMatchesByType("elimination")
|
||||
assert.Nil(t, err)
|
||||
if assert.Equal(t, 11, len(matches)) {
|
||||
assertMatch(t, matches[9], "10", 7, 5)
|
||||
assertMatch(t, matches[10], "12", 4, 3)
|
||||
assertMatch(t, matches[10], "11", 4, 3)
|
||||
}
|
||||
|
||||
scoreMatch(database, "9", game.RedWonMatch)
|
||||
@@ -122,8 +122,8 @@ func TestDoubleEliminationProgression(t *testing.T) {
|
||||
matches, err = database.GetMatchesByType("elimination")
|
||||
assert.Nil(t, err)
|
||||
if assert.Equal(t, 12, len(matches)) {
|
||||
assertMatch(t, matches[10], "11", 7, 8)
|
||||
assertMatch(t, matches[11], "12", 4, 3)
|
||||
assertMatch(t, matches[10], "11", 4, 3)
|
||||
assertMatch(t, matches[11], "12", 7, 8)
|
||||
}
|
||||
|
||||
scoreMatch(database, "11", game.RedWonMatch)
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestMatchupDisplayNames(t *testing.T) {
|
||||
|
||||
assert.Equal(t, "Finals", bracket.FinalsMatchup.LongDisplayName())
|
||||
assert.Equal(t, "F-1", bracket.FinalsMatchup.matchDisplayName(1))
|
||||
assert.Equal(t, "W 12", bracket.FinalsMatchup.RedAllianceSourceDisplayName())
|
||||
assert.Equal(t, "W 11", bracket.FinalsMatchup.RedAllianceSourceDisplayName())
|
||||
assert.Equal(t, "W 13", bracket.FinalsMatchup.BlueAllianceSourceDisplayName())
|
||||
|
||||
match13, err := bracket.GetMatchup(5, 1)
|
||||
@@ -25,8 +25,8 @@ func TestMatchupDisplayNames(t *testing.T) {
|
||||
assert.Equal(t, "Match 13", match13.LongDisplayName())
|
||||
assert.Equal(t, "13", match13.matchDisplayName(1))
|
||||
assert.Equal(t, "13-2", match13.matchDisplayName(2))
|
||||
assert.Equal(t, "L 12", match13.RedAllianceSourceDisplayName())
|
||||
assert.Equal(t, "W 11", match13.BlueAllianceSourceDisplayName())
|
||||
assert.Equal(t, "L 11", match13.RedAllianceSourceDisplayName())
|
||||
assert.Equal(t, "W 12", match13.BlueAllianceSourceDisplayName())
|
||||
|
||||
bracket, err = NewSingleEliminationBracket(8)
|
||||
assert.Nil(t, err)
|
||||
|
||||
7
main.go
7
main.go
@@ -1,14 +1,15 @@
|
||||
// Copyright 2014 Team 254. All Rights Reserved.
|
||||
// Author: pat@patfairbank.com (Patrick Fairbank)
|
||||
|
||||
// Go version 1.20 or newer is required due to how it initializes the PRNG.
|
||||
//go:build go1.20
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/Team254/cheesy-arena-lite/field"
|
||||
"github.com/Team254/cheesy-arena-lite/web"
|
||||
"log"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
const eventDbPath = "./event.db"
|
||||
@@ -16,8 +17,6 @@ const httpPort = 8080
|
||||
|
||||
// Main entry point for the application.
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
arena, err := field.NewArena(eventDbPath)
|
||||
if err != nil {
|
||||
log.Fatalln("Error during startup: ", err)
|
||||
|
||||
@@ -38,6 +38,7 @@ const (
|
||||
)
|
||||
|
||||
// Discrete inputs
|
||||
//
|
||||
//go:generate stringer -type=input
|
||||
type input int
|
||||
|
||||
@@ -59,6 +60,7 @@ const (
|
||||
)
|
||||
|
||||
// 16-bit registers
|
||||
//
|
||||
//go:generate stringer -type=register
|
||||
type register int
|
||||
|
||||
@@ -68,6 +70,7 @@ const (
|
||||
)
|
||||
|
||||
// Coils
|
||||
//
|
||||
//go:generate stringer -type=coil
|
||||
type coil int
|
||||
|
||||
@@ -84,6 +87,7 @@ const (
|
||||
)
|
||||
|
||||
// Bitmask for decoding fieldIoConnection into individual ArmorBlock connection statuses.
|
||||
//
|
||||
//go:generate stringer -type=armorBlock
|
||||
type armorBlock int
|
||||
|
||||
|
||||
@@ -211,8 +211,8 @@
|
||||
.bracket_double #match_3_2 {transform: translate(709px, 504px);}
|
||||
.bracket_double #match_3_1 {transform: translate(709px, 694px);}
|
||||
|
||||
.bracket_double #match_4_2 {transform: translate(1006px, 301px);}
|
||||
.bracket_double #match_4_1 {transform: translate(1006px, 599px);}
|
||||
.bracket_double #match_4_1 {transform: translate(1006px, 301px);}
|
||||
.bracket_double #match_4_2 {transform: translate(1006px, 599px);}
|
||||
|
||||
.bracket_double #match_5_1 {transform: translate(1302px, 567px);}
|
||||
|
||||
@@ -375,6 +375,16 @@
|
||||
<text transform="translate(640.2857 472.1667)" class="loser">L</text>
|
||||
</g>
|
||||
<g id="connectors_4_1"{{if (index .Matchups "4_1").IsActive}} class="active"{{end}}>
|
||||
<rect class="coverup" x="699.216" y="241.054" width="312.117" height="199.156"/>
|
||||
<polyline points="698,247 790,247 790,358 1010,358"/>
|
||||
<polyline points="698,437 790,437 790,421 1010,421"/>
|
||||
<text transform="translate(628.5344 429.1004)">W</text>
|
||||
<text transform="translate(628.5344 239.1004)">W</text>
|
||||
<text transform="translate(1263.0288 382.2166)">W</text>
|
||||
<text transform="translate(1239.3726 418.7044)" class="loser">L</text>
|
||||
<polyline class="loser" points="1256,391 1256,625 1323,625"/>
|
||||
</g>
|
||||
<g id="connectors_4_2"{{if (index .Matchups "4_2").IsActive}} class="active"{{end}}>
|
||||
<rect class="coverup" x="955.326" y="589.109" width="68.612" height="200.486"/>
|
||||
<text transform="translate(1223.2803 681.0883)">W</text>
|
||||
<text transform="translate(1223.3726 717.1893)" class="loser">L</text>
|
||||
@@ -386,16 +396,6 @@
|
||||
<polyline points="955,593 955,655 1008,655"/>
|
||||
<polyline points="955,783 955,725 1008,725"/>
|
||||
</g>
|
||||
<g id="connectors_4_2"{{if (index .Matchups "4_2").IsActive}} class="active"{{end}}>
|
||||
<rect class="coverup" x="699.216" y="241.054" width="312.117" height="199.156"/>
|
||||
<polyline points="698,247 790,247 790,358 1010,358"/>
|
||||
<polyline points="698,437 790,437 790,421 1010,421"/>
|
||||
<text transform="translate(628.5344 429.1004)">W</text>
|
||||
<text transform="translate(628.5344 239.1004)">W</text>
|
||||
<text transform="translate(1263.0288 382.2166)">W</text>
|
||||
<text transform="translate(1239.3726 418.7044)" class="loser">L</text>
|
||||
<polyline class="loser" points="1256,391 1256,625 1323,625"/>
|
||||
</g>
|
||||
<g id="connectors_5_1"{{if (index .Matchups "5_1").IsActive}} class="active"{{end}}>
|
||||
<rect class="coverup" x="1523.794" y="381.275" width="83.494" height="287.877"/>
|
||||
<polyline points="1481,390 1553,390 1553,474 1633,474"/>
|
||||
|
||||
@@ -7,10 +7,12 @@ import (
|
||||
"github.com/Team254/cheesy-arena-lite/game"
|
||||
"github.com/Team254/cheesy-arena-lite/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"math/rand"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCalculateRankings(t *testing.T) {
|
||||
rand.Seed(1)
|
||||
database := setupTestDb(t)
|
||||
|
||||
setupMatchResultsForRankings(database)
|
||||
|
||||
Reference in New Issue
Block a user