Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions src/main/java/com/tileman/TilemanModeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public interface TilemanModeConfig extends Config {
)
String customGameModeSection = "customGameMode";

@ConfigSection(
name = "Scaling",
description = "Increase the cost of your tiles as you unlock more tiles",
position = 100,
closedByDefault = true
)
String scalingSection = "scaling";

public enum TilemanGameMode {
COMMUNITY,
STRICT,
Expand Down Expand Up @@ -164,4 +172,76 @@ default boolean includeTotalLevel() {
default boolean excludeExp() {
return false;
}

/*** Scaling section ***/

@Range(
min = 1
)
@ConfigItem(
keyName = "scaleStartTile",
name = "Scale from x Tile",
description = "After which tile should next tiles cost increase",
section = scalingSection,
position = 1
)
default int scaleStartTile() {
return 1000;
}

@Range(
min = 1
)
@ConfigItem(
keyName = "scaleEveryTiles",
name = "Scale every x Tiles",
description = "After scaling starts, every how many Tiles should it scale again",
section = scalingSection,
position = 2
)
default int scaleEveryTiles() {
return 1000;
}

@Range(
min = 1
)
@ConfigItem(
keyName = "costIncreasePerScale",
name = "Scale cost Increase",
description = "How much xp cost should each instance of scaling add",
section = scalingSection,
position = 3
)
default int costIncreasePerScale() {
return 100;
}

@Range(
min = 1
)
@ConfigItem(
keyName = "baseTileCost",
name = "Base tile Cost",
description = "What is the tile cost before scaling",
section = scalingSection,
position = 4
)
default int baseTileCost() {
return 100;
}

@Range(
min = 1
)
@ConfigItem(
keyName = "maxTileCost",
name = "Max tile Cost",
description = "What is the Maximum cost of a tile",
section = scalingSection,
position = 4
)
default int maxTileCost() {
return 50000;
}
}
75 changes: 75 additions & 0 deletions src/main/java/com/tileman/TilemanModeScaling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.tileman;

public class TilemanModeScaling
{
private static int tilesUnlocked;
private static int tileCost;
private static int xpToNextTile;

public static void processScaling( int xp )
{
long scaleStartTile = //retrieve from config
long scaleEveryTiles = //retrieve from config
long costIncreasePerScale = //retrieve from config
long baseTileCost = //retrieve from config
long maxTileCost = //retrieve from config

long scale = 0;
long tiles = 0;
long cost = Math.min( baseTileCost, maxTileCost );
long nextScaleXp, remainder;

if( xp >= scaleStartTile * baseTileCost )
{
scale = 1;

tiles += scaleStartTile;
xp -= scaleStartTile * baseTileCost;

cost = Math.min( baseTileCost + costIncreasePerScale * scale, maxTileCost );
nextScaleXp = scaleEveryTiles * cost;
while( xp >= nextScaleXp )
{
tiles += scaleEveryTiles;
xp -= nextScaleXp;

cost = Math.min( baseTileCost + costIncreasePerScale * scale, maxTileCost );
nextScaleXp = scaleEveryTiles * cost;

scale++;
}

if( xp > cost )
{
tiles += xp / cost;
xp = xp % cost;
}
}
else
{
tiles += xp / baseTileCost;
xp = xp % baseTileCost;
}

remainder = cost - xp;

//cost == cost of next tile
//remainder == xp to next Tile
//tiles == available tiles at this xp
}

public static int getTilesUnlocked()
{
return tilesUnlocked;
}

public static int getTileCost()
{
return tileCost;
}

public static int getXpToNextTile()
{
return xpToNextTile;
}
}