@civ-clone/base-diplomacy
v0.1.3
Published
Baseline diplomacy a ruleset builds its rules from: contact, standing, war and peace, a computer player's stance and the steps of a meeting, with the ruleset's own numbers.
Readme
base-diplomacy
Baseline diplomacy a ruleset builds its rules from: contact, standing, war and peace, a computer player's stance at a meeting and the steps of the meeting itself. Each is a plain function, and the ruleset passes in its own content (who is a person, which units are nuclear, its leaders' tempers, which governments answer to a senate, the difficulty level) and its own numbers, so it keeps its own rule ids, numbers and registration:
lib/Dependencies: the registries the functions read.playerWorldRegistryis optional: onlyshareMapsneeds it.lib/Readers: what the ruleset tells them about its content.lib/standing:presence,landMassesOf,presenceOn,power,unitCount,gold,cityCount,atPeace,haveMet,atWar,traitScore,governedBy,rankFromTopandrankedFirst.lib/treatyLevel:treatyLevel(dependencies, player, other), how far the pair's treaties go (TreatyLevel: war < contact < ceasefire < peace < alliance);hasTreatyLevel(dependencies, player, other, level), whether they reachlevel, which stops looking once they do; andtreatyName.atPeaceishasTreatyLevel(..., TreatyLevel.Peace): ask these rather than looking for aPeace, so ceasefires and alliances count. War and contact differ only for rule sets that make ceasefires (makeCeasefireends the war).atWaris met with no treaty, a ceasefire counting as one; Civ1 has none, so for it that is met with no peace, as before.lib/contact:contactOnMove(interactionRegistry, unitRegistry), the criteria and effect of aMovedrule that makes contact between players whose units meet.lib/declareWar:declareWar(dependencies, player, other, forced?), which ends every treaty between them and tells theDeclaredWarrules (Rules/DeclaredWar:(by, against, forced, broken),brokentheTreatyLeveljust before) whetherplayerwas made to declare it;makePeace(which ends a ceasefire),makeCeasefire,makeAlliance(anAlliancebeside aPeace, so the pair stays at peace whencancelAllianceends it;cancelAlliancewith no alliance does nothing) andactiveDeclarations.lib/embassy:hasEmbassy(dependencies, player, other), one way: anEmbassyplayerholds withother, or anyHasEmbassyrule (Rules/HasEmbassy) answeringtrue, as a wonder that acts as an embassy with everyone would.lib/patience:patience(dependencies, holder, toward), withspent(),spend(amount?)andreset(): how much of a computer player's patience with another is used up, kept between meetings.lib/lastContact:lastContact(dependencies, player, other)andrecordContact(dependencies, player, other, turn): the turn the pair were last in contact.lib/shareMaps:shareMaps({ playerWorldRegistry }, player, other), each comes to know every square the other knows (and so what's on it: improvements and cities).lib/personMeeting: pieces for a meeting a person opens (Negotiation#initiator()), asMeetingSteprows:audience,proposalMenu(every proposal the ruleset makes that theProposalAvailablerules allow, then leaving),computerAnswer(from the ruleset'sanswer),patienceEnds, all of them inpersonMeetingSteps; andspendPatienceRules, anInteractionrule spending the computer player's patience with each proposal. Every row applies only when a person opened the negotiation, so a meeting a computer player opens (meetingSteps) is untouched;meetingForworks a meeting out from the first player's side, so don't ask it for these.lib/shamPeace:dropShamPeace(dependencies, player, random, chance), for aTurnStartrule.lib/stance:stance(dependencies, readers, numbers, player, other, random?, changeGovernment?), how a computer player comes to a meeting, withStanceNumbers.lib/wouldGoToWar:wouldGoToWar(dependencies, readers, threshold, player, other), whether two computer players meeting go to war.lib/meeting:meetingFor(dependencies, rules, negotiation, random), the meeting worked out once per negotiation,knownMeeting,negotiationOfandcalm.lib/meetingSteps:meetingSteps(dependencies, rules, numbers), the meeting's steps in order, each a criterion and what comes next, for the ruleset to makeSteprules of. Givenrules.isHuman, no row applies to a meeting a person opened (lib/personLed), so a ruleset can register these besidepersonMeetingSteps.lib/knowledge:advancesLackedandgive.lib/exchanged:recordTakenandtakenBy, what each player took in an exchange of knowledge.Records/PatienceRecordandRecords/LastContactRecord: the saved records behindpatienceandlastContact,RelationRecords in theInteractionRegistry, made only when a ruleset first writes one. Saves name them by class name, so a game that uses them registers them as saveable classes.Dialogues/AdvanceTaken: theDialoguein which a player says which advance it took in an exchange of knowledge (keyexchange-knowledge.taken). Saves name it by its class name, so a game registers it as a saveable class.lib/rules/*: rule assemblers, which build a ruleset's rules with its own id prefix (<prefix>:...) and numbers, rule for rule as civ1-diplomacy's:expiredRules,interactionRules,stepRules,mayNegotiateRules(withMeetingSpacing),turnStartRules,resolvedRules,detonatedRulesandmovedRules.
A library: it registers no rules. See civ1-diplomacy for Civilization's.
