Archive incari-client (client, 26.3, clean)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# hiteffects: Hit & Kill Effects
|
||||
|
||||
Particles on whatever you hit, and a bigger burst with a sound when it dies. Only you see them. ([ADR 0061](../../docs/adr/0061-cosmetics.md))
|
||||
|
||||
| Setting | Kind | Default |
|
||||
| --- | --- | --- |
|
||||
| On hit | on/off | on |
|
||||
| Hit effect | choice | Magic |
|
||||
| Hit particles | 1-20 | 6 |
|
||||
| On kill | on/off | on |
|
||||
| Kill effect | choice | Firework |
|
||||
| Kill particles | 5-60 | 30 |
|
||||
| Kill sound | on/off | on |
|
||||
|
||||
```sh
|
||||
./gradlew :features:hiteffects:check
|
||||
```
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
// Hit & Kill Effects (ADR 0061): particles on what the player hits, and a burst when it dies, on their screen only.
|
||||
// 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)
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package incari.features.hiteffects;
|
||||
|
||||
import incari.framework.Category;
|
||||
import incari.framework.Module;
|
||||
import incari.framework.event.Events;
|
||||
import incari.framework.game.Effect;
|
||||
import incari.framework.setting.BooleanSetting;
|
||||
import incari.framework.setting.ChoiceSetting;
|
||||
import incari.framework.setting.IntSetting;
|
||||
|
||||
/**
|
||||
* Hit & Kill Effects: particles on what the player hits, and a bigger burst when it dies. Drawn on
|
||||
* the player's screen only; the server and other players see the game's own.
|
||||
*/
|
||||
public final class HitEffects extends Module {
|
||||
|
||||
final BooleanSetting onHit =
|
||||
settings().bool("on-hit", "On hit", true).describedAs("Particles on whatever you hit.");
|
||||
final ChoiceSetting<Effect> hit = settings()
|
||||
.choice("hit", "Hit effect", Effect.values(), Effect.MAGIC, Effect::label)
|
||||
.describedAs("What shows when you hit.")
|
||||
.visibleWhen(onHit::get);
|
||||
final IntSetting hitCount = settings()
|
||||
.integer("hit-count", "Hit particles", 1, 20, 6)
|
||||
.describedAs("How many particles a hit makes.")
|
||||
.visibleWhen(onHit::get);
|
||||
final BooleanSetting onKill =
|
||||
settings().bool("on-kill", "On kill", true).describedAs("A burst when something you hit dies.");
|
||||
final ChoiceSetting<Effect> kill = settings()
|
||||
.choice("kill", "Kill effect", Effect.values(), Effect.FIREWORK, Effect::label)
|
||||
.describedAs("What shows when something you hit dies.")
|
||||
.visibleWhen(onKill::get);
|
||||
final IntSetting killCount = settings()
|
||||
.integer("kill-count", "Kill particles", 5, 60, 30)
|
||||
.describedAs("How many particles a kill makes.")
|
||||
.visibleWhen(onKill::get);
|
||||
final BooleanSetting killSound = settings()
|
||||
.bool("kill-sound", "Kill sound", true)
|
||||
.describedAs("Plays the effect's sound on a kill.")
|
||||
.visibleWhen(onKill::get);
|
||||
|
||||
/** Hit & Kill Effects, off until the player turns it on. */
|
||||
public HitEffects() {
|
||||
super(
|
||||
"hiteffects",
|
||||
"Hit & Kill Effects",
|
||||
"Shows particles on what you hit and a burst when it dies.",
|
||||
Category.COMBAT);
|
||||
on(Events.ATTACK, reach -> {
|
||||
if (onHit.get()) {
|
||||
system().game().effectOnTarget(hit.get(), hitCount.get(), false);
|
||||
}
|
||||
});
|
||||
on(Events.KILL, () -> {
|
||||
if (onKill.get()) {
|
||||
system().game().effectOnTarget(kill.get(), killCount.get(), killSound.get());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/** Hit & Kill Effects (ADR 0061): particles on what the player hits, and a burst when it dies, on their screen only. */
|
||||
@NullMarked
|
||||
package incari.features.hiteffects;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package incari.features.hiteffects;
|
||||
|
||||
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.hiteffects", 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.hiteffects..");
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package incari.features.hiteffects;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import incari.framework.game.Effect;
|
||||
import incari.framework.testing.TestGame;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class HitEffectsTest {
|
||||
|
||||
private final HitEffects module = new HitEffects();
|
||||
private final TestGame game = new TestGame(module);
|
||||
|
||||
@Test
|
||||
void showsAnEffectOnEachHitAndABurstOnAKill() {
|
||||
module.setEnabled(true);
|
||||
game.system().events().fireAttack(3);
|
||||
assertThat(game.effects).containsExactly(Effect.MAGIC);
|
||||
assertThat(game.effectCount).isEqualTo(6);
|
||||
assertThat(game.effectSound).isFalse();
|
||||
|
||||
game.kill();
|
||||
assertThat(game.effects).containsExactly(Effect.MAGIC, Effect.FIREWORK);
|
||||
assertThat(game.effectCount).isEqualTo(30);
|
||||
assertThat(game.effectSound).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void eachCanBeTurnedOff() {
|
||||
module.setEnabled(true);
|
||||
module.onHit.set(false);
|
||||
module.onKill.set(false);
|
||||
game.system().events().fireAttack(3);
|
||||
game.kill();
|
||||
assertThat(game.effects).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void nothingWhileOff() {
|
||||
game.system().events().fireAttack(3);
|
||||
game.kill();
|
||||
assertThat(game.effects).isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user