Skip to content

Commit

Permalink
Merge pull request #613 from Talia-12/environment-max-ops
Browse files Browse the repository at this point in the history
Make maxOpCount an Environment configurable value.
  • Loading branch information
Talia-12 authored Feb 8, 2024
2 parents b0a8530 + f902c69 commit 4181848
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public final ServerLevel getWorld() {
return this.world;
}

public int maxOpCount() {
return HexConfig.server().maxOpCount();
}

/**
* Get the caster. Might be null!
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public boolean toleratesOther(Iota that) {
continuation
);

if (result.getNewImage().getOpsConsumed() > HexConfig.server().maxOpCount()) {
if (result.getNewImage().getOpsConsumed() > vm.getEnv().maxOpCount()) {
throw new MishapEvalTooMuch();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import at.petrak.hexcasting.common.lib.hex.HexEvalSounds

object OpThanos : Action {
override fun operate(env: CastingEnvironment, image: CastingImage, continuation: SpellContinuation): OperationResult {
val opsLeft = HexConfig.server().maxOpCount() - image.opsConsumed
val opsLeft = env.maxOpCount() - image.opsConsumed
val stack = image.stack.toMutableList()
stack.add(DoubleIota(opsLeft.toDouble()))

Expand Down

0 comments on commit 4181848

Please sign in to comment.