chore: fix typos and add todos

This commit is contained in:
Mihail Pestrikov 2025-01-19 22:26:35 +00:00
parent 5ceadfbc9d
commit c5dde65270

View file

@ -68,13 +68,13 @@ func getSender() interop.Hash160 {
return runtime.GetScriptContainer().Sender
}
// Function for set room in storage with serialize
// Function to set room in storage with serialize
func setRoom(ctx storage.Context, room *Room) {
var serializedRoom = std.Serialize(room)
storage.Put(ctx, "room:"+room.Id, serializedRoom)
}
// Function for get room from storage with deserialize
// Function to get room from storage with deserialize
func getRoom(ctx storage.Context, roomId string) Room {
var roomData = storage.Get(ctx, "room:"+roomId)
@ -86,12 +86,12 @@ func getRoom(ctx storage.Context, roomId string) Room {
return room
}
// Function for send message to player, now it is default
// Function to send message to player, now it is default
func sendMessageToPlayer(message string, player Player) {
// todo: Сделать основную логику
}
// MAIN METHODS FOR PLAY IN GAME
// MAIN METHODS TO PLAY IN GAME
func CreateRoom(host interop.Hash160, countWinners int) string {
var ctx = storage.GetContext()
@ -165,7 +165,7 @@ func StartGame(roomId string) bool {
var room = getRoom(ctx, roomId)
if !room.Host.Equals(getSender()) || room.Status != RoomStatusWaiting || len(room.Players) <= room.CountWinners {
return false // Only host can start game, room status must be is waiting and players count must be > count winners
return false // Only host can start game, room status must be waiting and players count must be > count winners
}
for _, player := range room.Players {
@ -184,7 +184,7 @@ func AskQuestion(roomId string, question string) bool {
var room = getRoom(ctx, roomId)
if !room.Host.Equals(getSender()) || room.Status != RoomStatusGaming {
return false // Only host can ask question, room status must be game is started
return false // Only host can ask question, room status must be gaming
}
var round = Round{
@ -220,7 +220,7 @@ func SendAnswer(roomId string, text string) bool {
var wallet = getSender()
if !roomContainsPlayer(room.Players, wallet) || room.Status != RoomStatusAnswering {
return false // Only player can send content, room status must be round is started
return false // Only player can send content, room status must be answering
}
// todo: Добавить списание токенов за добавление ответа
@ -326,8 +326,8 @@ func chooseWonAnswers(round Round, countWinners int) []Answer {
return wonAnswers
}
// GetWinner todo: Нам сказали, что ссылку на другой контракт нельзя чисто, используем nns
func GetWinner(roomId string) bool {
// GetRoundWinner todo: Нам сказали, что ссылку на другой контракт нельзя чисто, используем nns
func GetRoundWinner(roomId string) bool {
var ctx = storage.GetContext()
var room = getRoom(ctx, roomId)
@ -370,9 +370,11 @@ func GetWinner(roomId string) bool {
func automaticFinishGame(ctx storage.Context, room *Room, voted int) bool {
if voted != len(room.Players) {
return false // All players must voted for finish the game
return false // All players must have voted to finish the game
}
// todo: Раз это завершение игры может произойти не в промежуточную фазу между раундами, надо подумать, что делать с наградами
// наверное последний раунд обрывать и определять победителя по предыдущим (как и обычно)
return finishGame(ctx, room)
}
@ -390,14 +392,14 @@ func VoteToFinishGame(roomId string) bool {
for i, p := range room.Players {
if p.Wallet.Equals(wallet) {
if p.IsVotedToFinish {
return false // Player is already voted to finish the game
return false // Player has already voted to finish the game
}
room.Players[i].IsVotedToFinish = true
isFound = true
}
if p.IsVotedToFinish {
voted++ // Count voted players for finish the game
voted++ // Count voted players to finish the game
}
}
@ -415,13 +417,15 @@ func ManuallyFinishGame(roomId string) bool {
var room = getRoom(ctx, roomId)
if !room.Host.Equals(getSender()) || room.Status != RoomStatusGaming {
return false // Only host can finish game, room status must be game is going
return false // Only host can finish game, room status must be gaming
}
return finishGame(ctx, &room)
}
func finishGame(ctx storage.Context, room *Room) bool {
// todo: Определение победителя игры
// todo: Отправка награды победителям и хосту
// todo: Нотификация результатов всей игры