Skip to content

Commit

Permalink
v1.3.2.1
Browse files Browse the repository at this point in the history
* Added config setting 'Enabled' (allows disabling the mod instead of unloading it)
* Added shop prices markup % indicators as item tooltips
  • Loading branch information
hamstar committed Jun 2, 2017
1 parent 716ec27 commit 52b1bff
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CapitalismMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Capitalism {
public class ConfigurationData {
public string VersionSinceUpdate = "";

public bool Enabled = true;

public float MarkupExponent = 0.8f;
public float MarkupDivisor = 50f;
public float TaxMarkupPercent = 1.02f;
Expand All @@ -25,7 +27,7 @@ public class ConfigurationData {


public class CapitalismMod : Mod {
public readonly static Version ConfigVersion = new Version(1, 3, 0);
public readonly static Version ConfigVersion = new Version(1, 3, 2);
public JsonConfig<ConfigurationData> Config { get; private set; }


Expand Down Expand Up @@ -88,6 +90,8 @@ public override void HandlePacket( BinaryReader reader, int whoAmI ) {
////////////////

public override void PostDrawInterface( SpriteBatch sb ) {
if( !this.Config.Data.Enabled ) { return; }

DebugHelper.PrintToBatch( sb );
}
}
Expand Down
6 changes: 6 additions & 0 deletions CapitalismNPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
namespace Capitalism {
class CapitalismNPC : GlobalNPC {
public override void SetupShop( int npc_type, Chest shop, ref int next_slot ) {
var mymod = (CapitalismMod)this.mod;
if( !mymod.Config.Data.Enabled ) { return; }

try {
Player player = Main.player[Main.myPlayer];
var modplayer = player.GetModPlayer<CapitalismPlayer>( this.mod );
Expand All @@ -20,6 +23,9 @@ public override void SetupShop( int npc_type, Chest shop, ref int next_slot ) {

public override bool CheckDead( NPC npc ) {
bool check = base.CheckDead( npc );
var mymod = (CapitalismMod)this.mod;
if( !mymod.Config.Data.Enabled ) { return check; }

try {
Player player = Main.player[Main.myPlayer];
if( player != null ) { return check; }
Expand Down
2 changes: 1 addition & 1 deletion CapitalismNetProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum CapitalismNetProtocolTypes : byte {



public class CapitalismNetProtocol {
public static class CapitalismNetProtocol {
public static void RoutePacket( CapitalismMod mymod, BinaryReader reader ) {
CapitalismNetProtocolTypes protocol = (CapitalismNetProtocolTypes)reader.ReadByte();

Expand Down
3 changes: 3 additions & 0 deletions CapitalismPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public override TagCompound Save() {
////////////////

public override void PreUpdate() {
var mymod = (CapitalismMod)this.mod;
if( !mymod.Config.Data.Enabled ) { return; }

this.Logic.Update( (CapitalismMod)this.mod, this.player );
}

Expand Down
11 changes: 9 additions & 2 deletions Logic/VendorLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,15 @@ public void UpdateShop( CapitalismMod mymod, Chest shop = null ) {
// Update only the first instance of an item
if( found_types.Contains(item.type) ) { continue; }
found_types.Add( item.type );

item.value = this.UpdateShopItem( mymod, item, shop );

int value = this.UpdateShopItem( mymod, item, shop );
double base_price = (double)this.BasePrices[ item.type ];
double markup = ((double)value - base_price) / base_price;

item.value = value;
if( markup >= 0.001d ) {
item.toolTip2 = "Has +" + (markup * 100d).ToString("N0") + "% markup";
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = hamstar
version = 1.3.1
version = 1.3.2.1
displayName = Capitalism
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
includePDB = false
Expand Down
3 changes: 3 additions & 0 deletions capitalism todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ v1.4.0
- Implement sell prices
- Add supply limits of items (based on price)

v1.3.2
- Add 'Enabled' config setting
- Add tooltips to shop items to indicate total markup
v1.2.1
- Change formula to use 'total spent' instead of 'total purchases'
v1.2.0
Expand Down

0 comments on commit 52b1bff

Please sign in to comment.