Skip to content

Commit

Permalink
Add base code
Browse files Browse the repository at this point in the history
  • Loading branch information
SeveralCircles committed Apr 12, 2023
1 parent 6afafa1 commit c3dd692
Show file tree
Hide file tree
Showing 14 changed files with 410 additions and 20 deletions.
204 changes: 204 additions & 0 deletions .idea/intellij-javadocs-4.0.1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/main/java/com/severalcircles/flames/Flames.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static void main(String[] args) {
});
flogger.info("Starting secondary managers");
managers2.add(new UserDataManager());
// managers2.add(TodayManager.newDay());
managers2.forEach(manager -> {
try {
manager.prepare();
Expand Down Expand Up @@ -123,7 +124,7 @@ public static FLogger getFlogger() {
// ------------------------
// Why is there a microwave
// A poem by Several Circles
// ------------------------
// -----------------------
// why do they call it an oven when it's clearly a microwave
// of in the cold food
// of out the hot food
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

public class SystemDataManager extends FlamesManager {
private static final File config = new File("flames.properties");
// private static final File secureSave = new File(System.getProperty("user.dir") + "/Flames/secure/securesave.sflp");
private static File flamesDirectory;
private static final Properties flamesConfig = new Properties();
@Override
Expand All @@ -42,6 +43,11 @@ public void prepare() throws IOException {
flamesDirectory.mkdir();
Flames.getFlogger().config("Created Flames directory at " + flamesDirectory.getAbsolutePath());
}
// if (!secureSave.exists()) {
// secureSave.createNewFile();
// Flames.getFlogger().config("Created secure save data at " + secureSave.getAbsolutePath());
// }

Flames.getFlogger().fine("System Data prepared.");
}
public void cleanFlamesFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.severalcircles.flames.data.user;

import com.severalcircles.flames.system.exception.AlreadyCollectedException;
import net.dv8tion.jda.api.entities.User;

import java.time.Instant;
Expand All @@ -22,8 +23,10 @@ public class FlamesUser {
private Locale locale;
private int consent;
private boolean quoteConsent;
private Instant lastBonus;
private double bonusMultiplier;

public FlamesUser(User discordUser, double score, Rank rank, double highScore, double lowScore, double emotion, Instant happyDay, Instant sadDay, FlamesQuote favoriteQuote, Locale locale, int consent, boolean quoteConsent) {
public FlamesUser(User discordUser, double score, Rank rank, double highScore, double lowScore, double emotion, Instant happyDay, Instant sadDay, FlamesQuote favoriteQuote, Locale locale, int consent, boolean quoteConsent, Instant lastBonus, double bonusMultiplier) {
this.discordUser = discordUser;
this.score = score;
this.rank = rank;
Expand All @@ -36,6 +39,8 @@ public FlamesUser(User discordUser, double score, Rank rank, double highScore, d
this.locale = locale;
this.consent = consent;
this.quoteConsent = quoteConsent;
this.lastBonus = lastBonus;
this.bonusMultiplier = bonusMultiplier;
}

public User getDiscordUser() {
Expand Down Expand Up @@ -123,4 +128,18 @@ public boolean gaveQuoteConsent() {
public void setQuoteConsent(boolean quoteConsent) {
this.quoteConsent = quoteConsent;
}

public Instant getLastBonus() {
return lastBonus;
}

public void setLastBonus(Instant lastBonus) {
this.lastBonus = lastBonus;
}
public double collectBonus() throws AlreadyCollectedException {
if (Instant.now().isBefore(lastBonus.plusSeconds(60 * 60 * 24 * 7))) throw new AlreadyCollectedException("You've already collected your bonus for this week!");
double bonus = 100 * bonusMultiplier;
bonusMultiplier += 0.1;
return bonus;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public FlamesUser loadUser(User user) throws IOException, ConsentException {
null,
Locale.forLanguageTag(properties.getProperty("locale")),
Integer.parseInt(properties.getProperty("consent")),
Boolean.parseBoolean(properties.getProperty("quoteConsent")));
Boolean.parseBoolean(properties.getProperty("quoteConsent")),
Instant.parse(properties.getProperty("lastBonus")));
fluser.setFavoriteQuote(FlamesQuote.valueOf(properties.getProperty("favoriteQuote"), fluser));}
catch (NullPointerException e) {
fluser = dataDefault(user);
Expand All @@ -83,7 +84,8 @@ public static FlamesUser flames() {
null,
Locale.forLanguageTag("en-US"),
1,
true);
true,
Instant.now());
}
public static FlamesUser dataDefault(User user) {
return new FlamesUser(
Expand All @@ -98,6 +100,7 @@ public static FlamesUser dataDefault(User user) {
null,
Locale.forLanguageTag("en-US"),
0,
false);
false,
Instant.now());
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/severalcircles/flames/frontend/DayPart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 Several Circles
*/

package com.severalcircles.flames.frontend;

public enum DayPart {
EARLY_MORNING(4, 6), MORNING(7, 11), AFTERNOON(12, 5), EVENING(6, 9), NIGHT(10, 12), MIDNIGHT(1, 3);
private final double hourStart;
private final double hourFinish;

DayPart(double hourStart, double hourFinish) {
this.hourStart = hourStart;
this.hourFinish = hourFinish;
}

public double getHourStart() {
return hourStart;
}

public double getHourFinish() {
return hourFinish;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023 Several Circles
*/

package com.severalcircles.flames.frontend;

import net.dv8tion.jda.api.entities.MessageEmbed;

import java.util.Locale;

@Embed(name = "WelcomeBack")
public class WelcomeBackEmbed extends FlamesEmbed {

public WelcomeBackEmbed(Locale locale) {
super(locale);
}

@Override
public MessageEmbed get() {
return null;
}
}
Loading

0 comments on commit c3dd692

Please sign in to comment.