Skip to content

Commit

Permalink
New ach
Browse files Browse the repository at this point in the history
  • Loading branch information
aunefyren committed Oct 31, 2023
1 parent e616ffb commit fa65832
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
18 changes: 16 additions & 2 deletions controllers/achievement.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ func CreateDefaultAchivements() error {
}
achievements = append(achievements, shameAchievement)

immuneAchievement := models.Achievement{
Name: "Superior immune system",
Description: "Don't use any sick leave throughout a season.",
SeasonBased: true,
}
achievements = append(achievements, immuneAchievement)

for _, achievement := range achievements {

_, err := database.RegisterAchievementInDB(achievement)
Expand All @@ -262,7 +269,6 @@ func CreateDefaultAchivements() error {
}

return nil

}

func ConvertAchivementDelegationToAchivementObject(achievementDelegation models.AchievementDelegation) (models.AchievementObject, error) {
Expand Down Expand Up @@ -527,7 +533,6 @@ func GenerateAchivementsForWeek(weekResults models.WeekResults) error {
}

func GenerateAchivementsForSeason(seasonResults []models.WeekResults) error {

type UserTally struct {
UserID int
LoseAmount int
Expand Down Expand Up @@ -695,6 +700,15 @@ func GenerateAchivementsForSeason(seasonResults []models.WeekResults) error {
}
}

// If sick leave amount is zero
if user.SickAmount == 0 {
// Give achivement to user
err := GiveUserAnAchivement(user.UserID, 23, seasonSunday)
if err != nil {
log.Println("Failed to give achivement for user '" + strconv.Itoa(user.UserID) + "'. Ignoring. Error: " + err.Error())
}
}

}

return nil
Expand Down
Binary file added web/assets/achievements/23.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions web/js/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ function place_news(news_array) {
document.getElementById("news-title").style.display = "inline-block"
}

var html = ''
news_object = document.getElementById("news-box")
news_object.innerHTML = "";

for(var i = 0; i < news_array.length; i++) {
var html = '';

// parse date object
try {
Expand Down Expand Up @@ -164,11 +166,10 @@ function place_news(news_array) {

html += '</div>'

news_object.innerHTML += html
}

news_object = document.getElementById("news-box")
news_object.innerHTML = html

return
}

function create_news() {
Expand Down

0 comments on commit fa65832

Please sign in to comment.