-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from KazeNoYumeX/feature/add-start-game
Feat: Added the Start Game API with the GAAS
- Loading branch information
Showing
46 changed files
with
792 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# |-------------------------------------------------------------------------- | ||
# | 基本設定 Basic | ||
# |-------------------------------------------------------------------------- | ||
APP_NAME="風聲-黑名單" | ||
APP_VERSION="v1" | ||
APP_FRONTEND_URL="https://messagefrontenddev.zeabur.app/" | ||
APP_BACKEND_URL="https://messagebackenddev.zeabur.app/api/" | ||
|
||
# |-------------------------------------------------------------------------- | ||
# | 資料庫設定 Database | ||
# |-------------------------------------------------------------------------- | ||
DB_HOST=127.0.0.1 | ||
DB_DATABASE=test | ||
DB_USER=user | ||
DB_PASSWORD=P@ssw0rd! | ||
DB_PORT=3306 | ||
DB_ROOT_PASSWORD=P@ssw0rd! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ import ( | |
|
||
func main() { | ||
db := config.NewDatabase() | ||
seeders.Run(db) | ||
seeders.OnlyCardsRun(db) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//go:build migrate | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/Game-as-a-Service/The-Message/config" | ||
"github.com/Game-as-a-Service/The-Message/database/seeders" | ||
_ "github.com/joho/godotenv/autoload" | ||
) | ||
|
||
func main() { | ||
db := config.NewDatabase() | ||
seeders.Run(db) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
BEGIN; | ||
|
||
DROP TABLE IF EXISTS deck_cards; | ||
DROP TABLE IF EXISTS decks; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
Backend/database/migrations/000007_add_intelligence_type_to_cards_table.down.sql
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
Backend/database/migrations/000007_add_intelligence_type_to_cards_table.up.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package seeders | ||
|
||
import ( | ||
"math/rand" | ||
|
||
"github.com/Game-as-a-Service/The-Message/enums" | ||
"github.com/Game-as-a-Service/The-Message/service/repository" | ||
"github.com/go-faker/faker/v4" | ||
"gorm.io/gorm" | ||
) | ||
|
||
func SeederGameWithPlayers(db *gorm.DB) { | ||
// Get all cards | ||
var cards []*repository.Card | ||
_ = db.Find(&cards) | ||
|
||
// Fake game data | ||
game := &repository.Game{ | ||
RoomID: faker.UUIDDigit(), | ||
Status: enums.ActionCardStage, | ||
Players: []repository.Player{}, | ||
} | ||
|
||
// Fake player count random 1~3 | ||
playerCount := rand.Intn(3) + 1 | ||
|
||
// Fake players data | ||
for i := 0; i < playerCount; i++ { | ||
player := repository.Player{ | ||
UserID: faker.UUIDDigit(), | ||
Name: faker.FirstName(), | ||
PlayerCards: []repository.PlayerCard{}, | ||
} | ||
|
||
// Each player gets 3 cards | ||
for j := 0; j < 3; j++ { | ||
player.PlayerCards = append(player.PlayerCards, repository.PlayerCard{ | ||
CardID: cards[i*3+j].ID, | ||
Type: "hand", | ||
}) | ||
} | ||
game.Players = append(game.Players, player) | ||
} | ||
|
||
_ = db.Create(&game) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.