feat: a make that can fail, and experience that depends on what is worn #104
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/smelting-roll"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Iron smelts half the time and the Goldsmith gauntlets pay 56.2 for a gold bar.
Both were stated in
smithing.exsand read by nothing.The roll is in the loop, not in the contract
Contract.Productionmust keep having no chance in it. A recipe never failsis what makes
runs/2andnet_slots/2arithmetic, andMake Allresolvesagainst that arithmetic before a single die is thrown — a roll inside the
contract would make the quantity a player asked for depend on luck they had
not had yet.
So
make/4rolls the recipe'schancethroughContract.Skilling.success?/2— the same roll every gathering skill takes —after consuming and before producing. A recipe with no
chanceis certain,which is every row in every other skill's file.
Three things about a failed make:
{:error, _}still means cannot make, whichstops the batch. A smelter who fails one ore goes on to the next.
certain_withoverrides the roll rather than improving it — a Ring offorging does not make iron likelier, it makes it sure — which is why its test
uses the dice that loses every time. It must be worn, and a separate test
asserts that the same ring in the pack does nothing.
diceis an argument with a default, matching the gathering loops: a teststates the roll rather than surviving it.
experience_withis a value, not a multiplier22.5 to 56.2 is a ratio of 2.4977…, so deriving the second from the first
gives 56.25 and starts a rounding argument nobody needs to have. The wiki
prints both numbers and the table carries both.
Woodcutting's Lumberjack outfit genuinely is a percentage and stays one.
These are not the same mechanic wearing a different hat, and the test says so
in its message.
A latent crash shipped in #103
animate/2has no catch-all clause, on purpose — a recipe that omitsanimationshould raise rather than silently show nothing. The four godswordhilt rows carried no
animationkey, so attaching a hilt would have raisedFunctionClauseErrorthe first time anybody did it. No test made a hilt, sonothing caught it.
Fixed with an explicit
animation: :none, plus a test that walks every recipein every table — pairs, screen rows and station products — and asserts the key
exists. That one now guards Fletching and Crafting too.
Three stale tests repaired
clicking Make-1 on the ring row makes a ring,Make-5 is op 2andthe mould survives every make of a batchall asserted that a make completesinline on the click. The skilling clock ended that deliberately, and the
neighbouring test —
nothing is made on the tick the batch starts— assertsthe new behaviour and passes in the same file. They were left red by that
change rather than by anything here, and now advance the clock a period
before asserting.
A comment corrected
The lovakite note claimed "Lovakengj smelts at its own furnace by its own
route". That was a conclusion nobody had checked: no loc anywhere in the
cache carries a
SmeltorForgeaction outside the sixteen furnacesalready declared. So either lovakite smelts at an ordinary furnace by a
route
311does not draw, or it is not smeltable in this cache at all. Thecomment now says that, and warns the next reader not to assume a second
furnace exists.
Not modelled
The Ring of forging's charges. It degrades after a number of iron bars in
the live game and nothing counts them, because no durability system exists.
The ring is currently infinite and the data file says so.
Checks
mix revenant.ci --gatespasses every leg, Dialyzer included.production_test.exsis 67/67, including 11 new tests.The failure picture, measured rather than argued
Ran
production_test.exsandplayers_test.exstogether on the bare base andagain with this diff. Bare base: 4 failures. With this branch: 1.
ProductionTestinline-makeWorld.TickSnapshotTest:setup?from the account-setup work and the expected list was not updatedDatabase.PlayersTestround tripWorld.Content.LightTestretryThe persistence one is worth its own issue rather than a shrug: prayer tenths
read 45, then 90, then 135 across successive runs, so the file-backed test
database is retaining rows between runs. It passes in isolation and fails in
company, which means it will keep reading as a random flake until the reset is
fixed. That is the same fixture-uniqueness bug the admin panel work hit once.
LightTestis deliberately untouched. Unlike the production three it is notobviously a stale assertion — the timer is gone where the test expects it
retained, which may be a real bug in the light loop, and guessing at it inside
a Smithing branch is how a wrong fix gets buried in an unrelated diff.
Iron smelts half the time and the Goldsmith gauntlets pay 56.2 for a gold bar. Both were stated in smithing.exs and read by nothing. The roll is in the loop and not in the contract, deliberately. Contract.Production must keep having no chance in it -- a recipe never fails is what makes runs/2 and net_slots/2 arithmetic, and Make All resolves against that arithmetic before a single die is thrown. So make/4 rolls the recipe's chance through Contract.Skilling.success?/2, after consuming and before producing, and a recipe with no chance is certain. Three things about a failed make. It consumes its inputs and produces nothing. It awards nothing. And it is not an error -- {:error, _} still means cannot make, which stops the batch, whereas a smelter who fails one ore goes on to the next. certain_with overrides the roll rather than improving it: a Ring of forging does not make iron likelier, it makes it sure, which is why its test uses the dice that loses every time. It has to be worn, and a test says so. Its charges are not modelled, because no durability system exists. experience_with states an alternative value rather than a multiplier. 22.5 to 56.2 is a ratio of 2.4977..., so deriving the second from the first gives 56.25 and starts a rounding argument. Woodcutting's Lumberjack outfit really is a percentage and stays one. Also fixes a latent crash shipped with the smithing table: animate/2 has no catch-all clause and the four hilt rows carried no animation key, so attaching a hilt would have raised the first time anybody did it. No test made a hilt. There is now one that walks every recipe in every table and asserts the key exists, which guards all three skills. Three tests in production_test asserted that a make completes inline on the click. The skilling clock ended that on purpose and the neighbouring test asserts the new behaviour, so these were left red by that change rather than by anything here. They now advance the clock a period before asserting. Corrects a comment that stated a conclusion nobody had checked: lovakite does not smelt at "its own furnace", because no loc anywhere in the cache carries a Smelt or Forge action outside the sixteen already declared.