Skip to content

Commit

Permalink
Changed Credit line
Browse files Browse the repository at this point in the history
  • Loading branch information
Platonymous committed Dec 27, 2018
1 parent 7e4fcf6 commit 0dc9f0e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions ATM/ATMMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using PyTK.Tiled;
using System.IO;
using StardewValley.Menus;
using System.Linq;

namespace ATM
{
Expand All @@ -22,6 +23,7 @@ public class ATMMod : Mod
public override void Entry(IModHelper helper)
{
config = helper.ReadConfig<Config>();
helper.WriteConfig(config);

helper.Events.GameLoop.Saving += OnSaving;
helper.Events.GameLoop.SaveLoaded += OnSaveLoaded;
Expand Down Expand Up @@ -115,7 +117,7 @@ private void OnDayStarted(object sender, DayStartedEventArgs e)

if (Game1.dayOfMonth == 1)
{
if (Game1.currentSeason.ToLower() == "spring")
if (config.CreditAdjustment.ToList().Contains(Game1.currentSeason.ToLower()))
setCreditLine();

payInterest();
Expand Down Expand Up @@ -144,7 +146,14 @@ private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)

private void setCreditLine()
{
int line = (int)(Math.Floor(Math.Floor(PyTK.PyUtils.calc(config.CreditLine, new KeyValuePair<string, object>("value", (Math.Max(0, bankAccount.Balance) + Game1.player.Money)))) / 1000) * 1000);
int value = (int)(Math.Max(0, Game1.player.money + bankAccount.Balance) / 28);
if (config.CreditInterest > 0)
value = (int)(value / config.CreditInterest) * 2;
else
value = value * 10;

int line = (int)(Math.Floor(PyTK.PyUtils.calc(config.CreditLine, new KeyValuePair<string, object>("value", Game1.player.totalMoneyEarned))));
line = Math.Max(line, 0);
if (line > bankAccount.CreditLine)
{
bankAccount.CreditLine = line;
Expand Down
3 changes: 2 additions & 1 deletion ATM/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ class Config
public string Map { get; set; } = "Town";
public int[] Position { get; set; } = new int[] { 32, 55 };
public bool Credit { get; set; } = true;
public string CreditLine { get; set; } = "value / 2";
public string CreditLine { get; set; } = "250 + (value / 2)";
public float CreditInterest { get; set; } = 0.05f;
public float GainInterest { get; set; } = 0.01f;
public string[] CreditAdjustment { get; set; } = new[] { "spring", "summer","fall","winter" };
}
}
2 changes: 1 addition & 1 deletion ATM/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "ATM",
"Author": "Platonymous",
"Version": "1.0.2",
"Version": "1.1.0",
"Description": "Adds an ATM to the Town",
"UniqueID": "Platonymous.ATM",
"EntryDll": "ATM.dll",
Expand Down
Binary file added _releases/ATM 1.0.3.zip
Binary file not shown.
Binary file added _releases/ATM 1.1.zip
Binary file not shown.
Binary file modified _releases/PyTK 1.6.2.zip
Binary file not shown.

0 comments on commit 0dc9f0e

Please sign in to comment.