Skip to content

Commit

Permalink
Cutting Contract check
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebRose committed Nov 18, 2024
1 parent 03de9fa commit 22bd51d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dbprovider/dbprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"

config "github.com/CalebRose/SimFBA/secrets"
"github.com/CalebRose/SimFBA/structs"
_ "github.com/jinzhu/gorm/dialects/mysql"
"golang.org/x/crypto/ssh"
"gorm.io/driver/mysql"
Expand Down Expand Up @@ -102,7 +103,7 @@ func (p *Provider) InitDatabase() bool {
// db.AutoMigrate(&models.NFLDraftee{})
// db.AutoMigrate(&models.NFLWarRoom{})
// db.AutoMigrate(&models.ScoutingProfile{})
// db.AutoMigrate(&structs.NFLContract{})
db.AutoMigrate(&structs.NFLContract{})
// db.AutoMigrate(&structs.NFLDepthChart{})
// db.AutoMigrate(&structs.NFLDepthChartPosition{})
// db.AutoMigrate(&structs.NFLExtensionOffer{})
Expand Down
4 changes: 2 additions & 2 deletions managers/PlayerManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ func GetNFLPlayersWithContractsByTeamID(TeamID string) []structs.NFLPlayer {
var players []structs.NFLPlayer

db.Preload("Contract", func(db *gorm.DB) *gorm.DB {
return db.Where("is_active = true")
return db.Where("is_active = true AND is_cut = false")
}).Where("team_id = ?", TeamID).Find(&players)

return players
Expand Down Expand Up @@ -1132,7 +1132,7 @@ func CutNFLPlayer(playerId string) {
player.WaivePlayer()
} else {
player.ToggleIsFreeAgent()
contract.DeactivateContract()
contract.CutContract()
}

capsheet.CutPlayerFromCapsheet(contract)
Expand Down
6 changes: 6 additions & 0 deletions structs/NFLContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ type NFLContract struct {
PlayerRetired bool
TagType uint8
IsTagged bool
IsCut bool
}

func (c *NFLContract) DeactivateContract() {
c.IsActive = false
}

func (c *NFLContract) CutContract() {
c.IsActive = false
c.IsCut = true
}

func (c *NFLContract) ReassignTeam(TeamID uint, Team string) {
c.TeamID = TeamID
c.Team = Team
Expand Down

0 comments on commit 22bd51d

Please sign in to comment.