Skip to content

Commit

Permalink
Merge branch 'main' into dudantas/feat-boosted-creature-and-event-sch…
Browse files Browse the repository at this point in the history
…eduler
  • Loading branch information
majestyotbr authored Jun 10, 2024
2 parents 95074a1 + 60aea1c commit bb33e70
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package api

import (
"database/sql"
"testing"

"github.com/gin-gonic/gin"
"github.com/opentibiabr/login-server/src/server"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"testing"
)

func TestApi_GetName(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions src/api/limiter/limiter.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package limiter

import (
"github.com/gin-gonic/gin"
"github.com/opentibiabr/login-server/src/configs"
"net/http"
"sync"
"time"

"github.com/gin-gonic/gin"
"github.com/opentibiabr/login-server/src/configs"

"golang.org/x/time/rate"
)

Expand Down
5 changes: 3 additions & 2 deletions src/api/login_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package api

import (
"reflect"
"testing"

"github.com/opentibiabr/login-server/src/api/models"
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"github.com/stretchr/testify/assert"
"reflect"
"testing"
)

var defaultString = "default"
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/character_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package models

import (
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"reflect"
"testing"

"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
)

func TestLoadCharactersFromMessage(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion src/api/models/session_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package models

import (
"testing"

"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"github.com/stretchr/testify/assert"
"testing"
)

func TestLoadSessionFromMessage(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions src/api/models/world_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package models

import (
"fmt"
"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"log"
"reflect"
"testing"

"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
)

func TestPlayground(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions src/configs/configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package configs

import (
"fmt"
"github.com/stretchr/testify/assert"
"golang.org/x/time/rate"
"log"
"os"
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/time/rate"
)

const defaultString = "default_string"
Expand Down
3 changes: 2 additions & 1 deletion src/configs/database_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package configs

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestDBConfigs_Format(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion src/configs/game_server_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package configs

import (
"github.com/stretchr/testify/assert"
"os"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestGameServerConfigs_Format(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions src/configs/login_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package configs

import (
"fmt"

"github.com/sirupsen/logrus"
"golang.org/x/time/rate"
)
Expand Down
5 changes: 3 additions & 2 deletions src/configs/login_server_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package configs

import (
"os"
"testing"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"golang.org/x/time/rate"
"os"
"testing"
)

func TestGetHttpLoginConfigs(t *testing.T) {
Expand Down
7 changes: 5 additions & 2 deletions src/database/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"database/sql"
"errors"
"fmt"
"log"
"time"

"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"github.com/opentibiabr/login-server/src/logger"
"time"
)

type Account struct {
Expand Down Expand Up @@ -35,6 +37,7 @@ func (acc *Account) Authenticate(db *sql.DB) error {

err := db.QueryRow(statement).Scan(&acc.ID, &acc.PremDays, &acc.LastDay)
if err != nil {
log.Println(err.Error())
return err
}

Expand All @@ -52,7 +55,7 @@ func (acc *Account) GetGrpcSession() *login_proto_messages.Session {

func (acc *Account) GetPremiumTime() uint64 {
if acc.PremDays > 0 {
return uint64(time.Now().Unix()) + uint64(acc.PremDays * secondsInADay)
return uint64(time.Now().Unix()) + uint64(acc.PremDays*secondsInADay)
}
return 0
}
Expand Down
5 changes: 3 additions & 2 deletions src/database/account_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package database

import (
"testing"
"time"

"bou.ke/monkey"
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

func TestAccount_GetGrpcSession(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions src/database/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package database

import (
"database/sql"

"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/logger"
)
Expand Down
6 changes: 5 additions & 1 deletion src/database/players.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"database/sql"
"fmt"

"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
)
Expand All @@ -23,6 +24,7 @@ func LoadPlayers(db *sql.DB, acc *Account) ([]*login_proto_messages.Character, e

defer rows.Close()

vocations := configs.GetServerVocations()
for rows.Next() {
player := login_proto_messages.Character{
WorldId: 0,
Expand All @@ -47,7 +49,9 @@ func LoadPlayers(db *sql.DB, acc *Account) ([]*login_proto_messages.Character, e
acc.LastLogin = player.Info.LastLogin
}

player.Info.Vocation = configs.GetServerVocations()[vocation]
if vocation < len(vocations) {
player.Info.Vocation = vocations[vocation]
}

players = append(players, &player)
}
Expand Down
3 changes: 2 additions & 1 deletion src/grpc/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package grpc_login_server

import (
"database/sql"
"net"

"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/database"
"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"github.com/opentibiabr/login-server/src/server"
"google.golang.org/grpc"
"net"
)

type GrpcServer struct {
Expand Down
3 changes: 2 additions & 1 deletion src/grpc/grpc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package grpc_login_server

import (
"database/sql"
"testing"

"github.com/opentibiabr/login-server/src/grpc/login_proto_messages"
"github.com/opentibiabr/login-server/src/server"
"github.com/stretchr/testify/assert"
"testing"
)

func TestGrpcServer_GetName(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions src/grpc/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package grpc_login_server

import (
"context"

"github.com/opentibiabr/login-server/src/api/models"
"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/database"
Expand Down
7 changes: 4 additions & 3 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package main

import (
"fmt"
"sync"
"time"

"github.com/opentibiabr/login-server/src/api"
"github.com/opentibiabr/login-server/src/configs"
"github.com/opentibiabr/login-server/src/grpc"
grpc_login_server "github.com/opentibiabr/login-server/src/grpc"
"github.com/opentibiabr/login-server/src/logger"
"github.com/opentibiabr/login-server/src/server"
"sync"
"time"
)

var numberOfServers = 2
Expand Down

0 comments on commit bb33e70

Please sign in to comment.