Skip to content
Snippets Groups Projects
Commit b55267cb authored by ForkBench's avatar ForkBench
Browse files

Adding Faker and Randomness when adding player.

parent 625ede2d
No related branches found
No related tags found
No related merge requests found
...@@ -19,3 +19,25 @@ type Club struct { ...@@ -19,3 +19,25 @@ type Club struct {
func (n *Nation) GetFlagPath() string { func (n *Nation) GetFlagPath() string {
return "https://flagsapi.com/" + n.NationCode + "/flat/64.png" return "https://flagsapi.com/" + n.NationCode + "/flat/64.png"
} }
func GenerateNation() *Nation {
return &Nation{
NationID: 69,
NationName: "France",
NationCode: "FR",
}
}
func GenerateRegion() *Region {
return &Region{
RegionID: 16,
RegionName: "OCCITANIE",
}
}
func GenerateClub() *Club {
return &Club{
ClubID: 73,
ClubName: "BERGERAC CAD",
}
}
package services package services
import (
"math/rand/v2"
"github.com/go-faker/faker/v4"
)
// Player : Person details // Player : Person details
type Player struct { type Player struct {
PlayerID uint16 // More than 255 players PlayerID uint16 // More than 255 players
...@@ -36,3 +42,15 @@ type Referee struct { ...@@ -36,3 +42,15 @@ type Referee struct {
func (r Referee) String() string { func (r Referee) String() string {
return "Referee : " + r.RefereeFirstname + " " + r.RefereeLastname return "Referee : " + r.RefereeFirstname + " " + r.RefereeLastname
} }
func (p *Player) GenerateRandomPlayer() *Player {
return &Player{
PlayerID: 65535,
PlayerFirstname: faker.FirstName(),
PlayerLastname: faker.LastName(),
PlayerClub: GenerateClub(),
PlayerNation: GenerateNation(),
PlayerRegion: GenerateRegion(),
PlayerInitialRank: uint16(rand.Uint32()/2) % 100,
}
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import * as Models from "../../../bindings/changeme/astro/services/models"; import * as Models from "../../../bindings/changeme/astro/services/models";
import * as Session from "../../../bindings/changeme/astro/services/session"; import * as Session from "../../../bindings/changeme/astro/services/session";
import { SelectedCompetition } from "../../store"; import { SelectedCompetition } from "../../store";
import { GenerateRandomPlayer } from "../../../bindings/changeme/astro/services/player";
import swal from "sweetalert"; import swal from "sweetalert";
let players: (Models.Player | null)[] = []; let players: (Models.Player | null)[] = [];
...@@ -228,8 +229,8 @@ ...@@ -228,8 +229,8 @@
}}>{player.PlayerLastname}</td }}>{player.PlayerLastname}</td
> >
<td <td
>{#if player.PlayerClub}{player.PlayerClub}{:else}Sans >{#if player.PlayerClub}{player.PlayerClub
Nom{/if}</td .club_name}{:else}Sans Nom{/if}</td
> >
</tr> </tr>
{/if} {/if}
...@@ -238,15 +239,8 @@ ...@@ -238,15 +239,8 @@
<td colspan="4"> <td colspan="4">
<button <button
on:click={async () => { on:click={async () => {
var player = Models.Player.createFrom({ var player = await GenerateRandomPlayer();
PlayerID: 65535,
PlayerFirstname: "Firstname",
PlayerLastname: "Lastname",
PlayerNationID: 0,
PlayerClubID: 0,
PlayerRegionID: 0,
PlayerInitialRank: 2,
});
if (competition != undefined) if (competition != undefined)
await Session.AddPlayerToCompetition( await Session.AddPlayerToCompetition(
competition.CompetitionID, competition.CompetitionID,
......
...@@ -2,7 +2,10 @@ module changeme ...@@ -2,7 +2,10 @@ module changeme
go 1.22.4 go 1.22.4
require github.com/wailsapp/wails/v3 v3.0.0-alpha.0 require (
github.com/go-faker/faker/v4 v4.4.2
github.com/wailsapp/wails/v3 v3.0.0-alpha.0
)
require ( require (
dario.cat/mergo v1.0.0 // indirect dario.cat/mergo v1.0.0 // indirect
...@@ -44,7 +47,8 @@ require ( ...@@ -44,7 +47,8 @@ require (
golang.org/x/net v0.25.0 // indirect golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.7.0 // indirect golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect golang.org/x/sys v0.20.0 // indirect
golang.org/x/tools v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect
) )
......
...@@ -28,6 +28,8 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc ...@@ -28,6 +28,8 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
github.com/go-faker/faker/v4 v4.4.2 h1:96WeU9QKEqRUVYdjHquY2/5bAqmVM0IfGKHV5mbfqmQ=
github.com/go-faker/faker/v4 v4.4.2/go.mod h1:4K3v4AbKXYNHMQNaREMc9/kRB9j5JJzpFo6KHRvrcIw=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
...@@ -167,14 +169,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= ...@@ -167,14 +169,14 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment