Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# saturation: Saturation
|
||||
|
||||
Shows saturation, the hidden food value that keeps hunger from dropping, on the hunger bar: each
|
||||
shank's worth outlines that shank in a bright color, from the right, as AppleSkin does. When the
|
||||
outline is gone, hunger starts going down.
|
||||
|
||||
| Setting | Kind | Default |
|
||||
| --- | --- | --- |
|
||||
| Color | colour | Gold |
|
||||
|
||||
```sh
|
||||
./gradlew :features:saturation:check
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
// Saturation: the player's saturation shown on the hunger bar.
|
||||
// A feature module: it sees the module framework and nothing else.
|
||||
dependencies {
|
||||
api(project(":framework"))
|
||||
|
||||
testImplementation(testFixtures(project(":framework")))
|
||||
testImplementation(platform(libs.junit.bom))
|
||||
testImplementation(libs.junit.jupiter)
|
||||
testImplementation(libs.assertj)
|
||||
testImplementation(libs.archunit)
|
||||
testRuntimeOnly(libs.junit.launcher)
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package incari.features.saturation;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.event.Events;
|
||||
import incari.framework.setting.ColorSetting;
|
||||
|
||||
/**
|
||||
* Saturation: the hidden food value that keeps hunger from dropping, shown on the hunger bar. Each
|
||||
* shank's worth of saturation outlines that shank in a bright color, from the right as hunger
|
||||
* fills, as AppleSkin does; when no outline is left, hunger is about to start going down.
|
||||
*/
|
||||
public final class Saturation extends Module {
|
||||
|
||||
final ColorSetting color =
|
||||
settings().color("color", "Color", 0xFFCC00).describedAs("The color saturated shanks are outlined in.");
|
||||
|
||||
/** Saturation, off until the player turns it on. */
|
||||
public Saturation() {
|
||||
super("saturation", "Saturation", "Shows your saturation on the hunger bar.", Category.HUD);
|
||||
on(Events.TICK, this::apply);
|
||||
}
|
||||
|
||||
private void apply() {
|
||||
system().game().overrideSaturation(color.get() & 0xFFFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
system().game().overrideSaturation(-1);
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** Saturation: the player's saturation shown on the hunger bar. */
|
||||
@NullMarked
|
||||
package incari.features.saturation;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.saturation;
|
||||
|
||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
|
||||
|
||||
import com.tngtech.archunit.core.importer.ImportOption;
|
||||
import com.tngtech.archunit.junit.AnalyzeClasses;
|
||||
import com.tngtech.archunit.junit.ArchTest;
|
||||
import com.tngtech.archunit.lang.ArchRule;
|
||||
|
||||
/** A feature sees the module framework and the JDK's basics: no game, platform or other feature. */
|
||||
@AnalyzeClasses(packages = "incari.features.saturation", importOptions = ImportOption.DoNotIncludeTests.class)
|
||||
class BoundaryTest {
|
||||
|
||||
@ArchTest
|
||||
static final ArchRule onlyTheFramework = classes()
|
||||
.should()
|
||||
.onlyDependOnClassesThat()
|
||||
.resideInAnyPackage(
|
||||
"java.lang..",
|
||||
"java.util..",
|
||||
"org.jspecify..",
|
||||
"incari.framework..",
|
||||
"incari.features.saturation..");
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package incari.features.saturation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class SaturationTest {
|
||||
|
||||
private final Saturation module = new Saturation();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void tintsTheHungerBarWhileOn() {
|
||||
assertThat(game.saturationColor).isEqualTo(-1);
|
||||
module.setEnabled(true);
|
||||
assertThat(game.saturationColor).isEqualTo(0xFFCC00);
|
||||
module.color.set(0x00FF00);
|
||||
game.tick();
|
||||
assertThat(game.saturationColor).isEqualTo(0x00FF00);
|
||||
// Black is a color like any other, not "off".
|
||||
module.color.set(0);
|
||||
game.tick();
|
||||
assertThat(game.saturationColor).isZero();
|
||||
module.setEnabled(false);
|
||||
assertThat(game.saturationColor).isEqualTo(-1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user