This repository has been archived on 2022-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
dcbot-old/utils/tribalwars.go

38 lines
941 B
Go

package utils
import (
"fmt"
"github.com/tribalwarshelp/shared/models"
)
const (
endpointTribeProfile = "/game.php?screen=info_ally&id=%d"
endpointPlayerProfile = "/game.php?screen=info_player&id=%d"
endpointVillageProfile = "/game.php?screen=info_village&id=%d"
)
func FormatVillageURL(world, host string, id int) string {
return fmt.Sprintf("https://%s.%s"+endpointVillageProfile, world, host, id)
}
func FormatTribeURL(world, host string, id int) string {
return fmt.Sprintf("https://%s.%s"+endpointTribeProfile, world, host, id)
}
func FormatPlayerURL(world, host string, id int) string {
return fmt.Sprintf("https://%s.%s"+endpointPlayerProfile, world, host, id)
}
func IsPlayerNil(player *models.Player) bool {
return player == nil
}
func IsPlayerTribeNil(player *models.Player) bool {
return IsPlayerNil(player) || player.Tribe == nil
}
func IsVillageNil(village *models.Village) bool {
return village == nil
}