A repository for a FoundryVTT plugin for Kingmaker homebrew.

Need to implement fix to error when activity could be performed by any leader

+274 -4
+132
public/lang/en.json
··· 1320 1320 "msg": "Choose one of the following effects: you demolish an entire multiple-lot structure all at once and clear all of the lots it occupied, or you recover [[/r 1d6#Commodities]] Commodities (chosen from lumber, stone, and ore) from the Rubble of a single-lot demolition." 1321 1321 } 1322 1322 ] 1323 + }, 1324 + "deploy-army": { 1325 + "title": "Deploy Army", 1326 + "description": "Leader: **General**\n\nThe army moves through your kingdom or beyond. Since this travel occurs over the course of the entire month that preceded the Kingdom turn, the ground an army covers when it deploys can be quite extensive. You can Deploy an Army with a Arcana, Athletics, Nature, Occultism, Religion, Sailing Lore, or Survival check.\n\n* **Nature or Survival**: Choose a location within 20 hexes of the army's current hex. If the army's starting point and ending point are connected by a road, increase the result one degree of success. Count roadless hexes that contain swamps or mountains, or each hex where you must cross a river or lake without the aid of a bridge, as two hexes. You can issue orders to force march. Doing so grants a +4 circumstance bonus on the check, but causes the army to increase its sickened condition by 1 (or by 2, if you fail the check).\n* **Athletics, Sailing Lore, or Nature**: The army's starting point and ending point must be connected by a body of water; choose any location within 20 hexes along this route.\n* **Arcana, Nature, Occultism, or Religion**: You must be at least master in the skill used to attempt this option. When you do so, choose any location within 30 hexes of the army's current hex, then roll your check. If the army's deployment causes it to cross your kingdom's border, the DC increases by 5. If the army's deployment causes it to cross an enemy kingdom's border, the DC instead increases by 10.", 1327 + "results": [ 1328 + { 1329 + "msg": "Rather than arriving at its destination, the army becomes lost until it recovers from this condition. @{gainLose gainLose=gain amount=1d4 amountType=roll resource=unrest label=\"Gain 1d4 Unrest\"}, and attempt a DC 11 flat check; on a failure, remove one of the army's HP segments." 1330 + }, 1331 + { 1332 + "msg": "The army arrives at its destination, but ran into some sort of trouble along the way. Increase the army's sickened condition by 1 and attempt a DC 6 flat check; on a failure, remove one of the army's HP segments." 1333 + }, 1334 + { 1335 + "msg": "The army arrives at its destination." 1336 + }, 1337 + { 1338 + "msg": "The army arrives much more quickly than you anticipated; it arrives at its destination and then becomes efficient. You may attempt a second Army activity immediately, but doing so causes the army to lose the efficient condition. This second Army activity suffers a -5 penalty on its check, and the result of this second activity cannot grant the efficient condition. If the army doesn't attempt a second Army activity, it instead loses the efficient condition and reduces the value of one condition of its choice by 1." 1339 + } 1340 + ] 1341 + }, 1342 + "garrison-army": { 1343 + "title": "Garrison Army", 1344 + "description": "Leader: **General**\n\n**Requirements** The army is in the same hex as a Refuge, Settlement, or Work Site.\n\nYou move an army into a fortification and assign them to guard it. In order to garrison, the army must be located in a hex that contains a Refuge, Settlement, or Work Site. If you're garrisoning the army in a Refuge hex, attempt a basic Warfare Lore or Crafting check. If you're garrisoning the army in a settlement, attempt a basic Diplomacy, Deception, or Society check. If you're garrisoning the army in a Work Site hex, attempt a basic Engineering Lore or Crafting check. This check's DC increases by 5 if the hex is not part of your kingdom, or by 10 if the location is part of an enemy kingdom.", 1345 + "results": [ 1346 + { 1347 + "msg": "Your army clashes with local citizens, abuses their authority, lets their watchful readiness slack, and/or provokes confrontations where they are not needed. It does not gain cover, and you cannot attempt to garrison that army at this location again for 4 Kingdom turns. @{gainLose gainLose=gain amount=1 amountType=value resource=unrest label=\"Gain 1 Unrest\"}." 1348 + }, 1349 + { 1350 + "msg": "The army gains greater cover until the next Kingdom turn begins, at which point you must use this activity again to maintain greater cover." 1351 + }, 1352 + { 1353 + "msg": "The army gains greater cover until it is deployed." 1354 + }, 1355 + { 1356 + "msg": "The army gains greater cover until it is deployed. Additionally, the efficiency of the garrisoning reduces this army's Consumption by 2 (to a minimum of 1) until it is deployed." 1357 + } 1358 + ] 1359 + }, 1360 + "offensive-gambit": { 1361 + "title": "Offensive Gambit", 1362 + "description": "Leader: **General**\n\n**Requirements** You have at least one army in the same hex as an enemy army.\n\nYou order an attack against an enemy army, causing a war encounter to begin after this Kingdom turn ends. No check is necessary if you wish to engage the enemy without attempting to gain an advantage in initiative. If you want to gain an advantage by surprising the enemy, attempt an Deception, Diplomacy, or Society check. If you want to gain an advantage by intimidating the enemy, attempt a Warfare Lore, Intimidation, or Athletics check. In either case, the DC is equal to the enemy army's Perception DC. This uses the highest enemy Perception DC.", 1363 + "results": [ 1364 + { 1365 + "msg": "Not only do you fail to gain advantage, but the enemy forces have anticipated the attack. Enemy armies in this hex at the time of the Offensive Gambit gain a +4 circumstance bonus on their initiative checks in any resulting war encounters." 1366 + }, 1367 + { 1368 + "msg": "You gain no advantage in the battle." 1369 + }, 1370 + { 1371 + "msg": "Your approach gives you an advantage. Your armies in this hex gain a +2 circumstance bonus on their initiative checks." 1372 + }, 1373 + { 1374 + "msg": "Your approach surprises or intimidates the enemy. Your armies in this hex gain a +2 circumstance bonus on their initiative checks, and one enemy army of the party's choice in this hex becomes frightened 1." 1375 + } 1376 + ] 1377 + }, 1378 + "outfit-army": { 1379 + "title": "Outfit Army", 1380 + "description": "Leader: **Any**\n\nYou provide your army with better gear. Choose what sort of gear you wish to provide your army with from the list below. The level of the gear chosen must be equal to or less than the army's level. If you're crafting or purchasing gear, the level of the gear chosen must be equal to or less than your kingdom level. If you're distributing resources gained from battle, the level of the gear chosen must be equal to or less than the highest level of an enemy army defeated in that battle.\n\nIf you're purchasing the gear, this activity requires a basic Mercantile Lore, Society, or Deception check and costs the standard amount of RP for the gear; you cannot purchase magic gear unless your kingdom's leader attempting the check is at least expert rank in Arcana, Nature, Occultism, or Religion.\n\nIf you're distributing gear gained from battle, this activity requires a basic Warefare Lore check and does not cost RP.\n\n* **Healing Potions**: @{gainLose gainLose=lose amount=15 resource=resourcePoints amountType=value label=\"Spend 15 RP\"} per dose. Heals one entire HP segment and costs two actions to consume.\n* **Magic Armor (Level 5)**: @{gainLose gainLose=lose resource=resoursePoints amount=25 amountType=value label=\"Spend 25 RP\"}. Increases AC by 1.\n* **Magic Armor (Level 11)**: @{gainLose gainLose=lose resource=resoursePoints amount=50 amountType=value label=\"Spend 50 RP\"}. Increases AC by 2.\n* **Magic Armor (Level 18)**: @{gainLose gainLose=lose resource=resoursePoints amount=75 amountType=value label=\"Spend 75 RP\"}. Increases AC by 3.\n* **Magic Weapon (Level 2)**: @{gainLose gainLose=lose resource=resoursePoints amount=20 amountType=value label=\"Spend 20 RP\"}. Increases attack bonus by 1.\n* **Magic Weapon (Level 10)**: @{gainLose gainLose=lose resource=resoursePoints amount=40 amountType=value label=\"Spend 40 RP\"}. Increases attack bonus by 2.\n* **Magic Weapon (Level 16)**: @{gainLose gainLose=lose resource=resoursePoints amount=60 amountType=value label=\"Spend 60 RP\"}. Increases attack bonus by 3.", 1381 + "results": [ 1382 + { 1383 + "msg": "The gear proves to be unusable and the attempt to outfit the army fails. Your RP is not refunded." 1384 + }, 1385 + { 1386 + "msg": "The gear proves to be unusable and the attempt to outfit the army fails. If you spent RP on the check, it is refunded." 1387 + }, 1388 + { 1389 + "msg": "The gear is sufficient, and your army becomes outfitted with it immediately." 1390 + }, 1391 + { 1392 + "msg": "The gear proved particularly easy to outfit, and the army becomes efficient. You may attempt a second Army activity immediately, but doing so causes the army to lose the efficient condition. This second Army activity suffers a -5 penalty on its check, and the result of this second activity cannot grant the efficient condition. If the army doesn't attempt a second Army activity, it instead loses the efficient condition and reduces the value of one condition of its choice by 1." 1393 + } 1394 + ] 1395 + }, 1396 + "recover-army": { 1397 + "title": "Recover Army", 1398 + "description": "Leader: **General**\n\nWhen an army endures ill fortune, it can become afflicted by negative conditions. You can use the Recover Army activity to work at removing an affliction with a basic skill check (this DC increases by 5 if you are attempting to Recover from the defeated condition); the skill required for the check depends on the affliction.\n\n* **Recover HP Segments**: Warfare Lore, Crafting, Arcana, Occultism (expert), Society (expert)\n* **Sickened**: Warfare Lore, Nature, Athletics, Performance (expert), Crafting (expert), Society (expert)\n* **Frightened**: Performance, Crafting, Society, Warfare Lore (expert), Intimidation (expert)\n* **Drained**: Crafting, Arcana (expert), Nature (expert), Occultism (expert), Religion (expert)", 1399 + "results": [ 1400 + { 1401 + "msg": "You fail to remove the affliction and your soldier's lowered morale spreads discontent; @{gainLose gainLose=gain amount=1 amountType=value resource=unrest label=\"Gain 1 Unrest\"}. If you were attempting to recover a defeated army, the army is destroyed." 1402 + }, 1403 + { 1404 + "msg": "You fail to remove the affliction." 1405 + }, 1406 + { 1407 + "msg": "As critical success but you reduce the affliction's value by 1 (or in the case of a damaged army, recover one HP segment)." 1408 + }, 1409 + { 1410 + "msg": "You reduce the affliction's value by 2 (or in the case of a damaged army, recover two HP segments). If the affliction does not have a value, it is removed." 1411 + } 1412 + ] 1413 + }, 1414 + "recruit-army": { 1415 + "title": "Recruit Army", 1416 + "description": "Leader: **General**\n\nNote that you pursue this activity during the Leadership step of the Activity phase. Either you recruit an army from your kingdom's citizens, or you secure the allegiance of a specialized army you encountered in the Stolen Lands. If you're recruiting an army from your kingdom's citizens, attempt a Warfare check against the army's Recruitment DC. If you're securing a specialized army, you must attempt a Warfare Lore, Athletics, or Intimidation check against their Will DC.", 1417 + "results": [ 1418 + { 1419 + "msg": "Many of the individuals in the army you attempted to recruit took offense at the attempt. @{gainLose gainLose=gain amount=1 amountType=value resource=unrest label=\"Gain 1 Unrest\"}, and you cannot attempt to recruit an army again until the next Kingdom turn." 1420 + }, 1421 + { 1422 + "msg": "You fail to recruit the army." 1423 + }, 1424 + { 1425 + "msg": "You recruit the army." 1426 + }, 1427 + { 1428 + "msg": "You recruit the army; it becomes efficient. You may attempt a second Army activity immediately, but doing so causes the army to lose the efficient condition. This second Army activity suffers a -5 penalty on its check, and the result of this second activity cannot grant the efficient condition. If the army doesn't attempt a second Army activity, it instead loses the efficient condition and reduces the value of one condition of its choice by 1." 1429 + } 1430 + ] 1431 + }, 1432 + "train-army": { 1433 + "title": "Train Army", 1434 + "description": "You train an army in the use of a tactic. Choose to either learn a Skirmish Bond, remove the Weak template, or apply the Elite template, then attempt an Arcana, Occultism, Religion, Academia Lore, Warfare Lore, Intimidation, or Athletics check against the army's Fortitude DC. A unit can never be raised above your kingdom's level in this fashion.", 1435 + "results": [ 1436 + { 1437 + "msg": "The army not only fails to gain the Skirmish Bond, remove the Weak template, or apply the Elite template but becomes frustrated and exhausted from the training; increase the army's sickened condition by 1." 1438 + }, 1439 + { 1440 + "msg": "The army fails to gain the Skirmish Bond, remove the Weak template, or apply the Elite template." 1441 + }, 1442 + { 1443 + "msg": "The army gains the Skirmish Bond, removes the Weak template, or applies the Elite template." 1444 + }, 1445 + { 1446 + "msg": "The army gains the Skirmish Bond, removes the Weak template, or applies the Elite template and then becomes efficient. You may attempt a second Army activity immediately, but doing so causes the army to lose the efficient condition. This second Army activity suffers a -5 penalty on its check, and the result of this second activity cannot grant the efficient condition. If the army doesn't attempt a second Army activity, it instead loses the efficient condition and reduces the value of one condition of its choice by 1." 1447 + } 1448 + ] 1323 1449 } 1324 1450 }, 1325 1451 "turns": { ··· 1338 1464 "adjustUnrest": "Adjust Unrest", 1339 1465 "collectResources": "Collect Resources", 1340 1466 "payConsumption": "Pay Consumption" 1467 + }, 1468 + "army": { 1469 + "disband-army": { 1470 + "title": "Disband Army", 1471 + "desc": "You can choose to disband an army with no check needed. If the army consisted of conscripts from your kingdom, the soldiers revert to being citizens. If the army was recruited from creatures encountered in the wilds, they return to their homes. A disbanded army no longer contributes to your kingdom's Consumption." 1472 + } 1341 1473 } 1342 1474 }, 1343 1475 "perform": "Perform",
+117
src/data/activities.json
··· 535 535 "religion" 536 536 ] 537 537 } 538 + }, 539 + { 540 + "id": "recruit-army", 541 + "rollData": { 542 + "leader": "general", 543 + "skills": [ 544 + "warfare-lore", 545 + "athletics", 546 + "intimidation", 547 + "diplomacy", 548 + "deception", 549 + "society" 550 + ] 551 + } 538 552 } 539 553 ], 540 554 "region": [ ··· 702 716 "skills": [ 703 717 "engineering-lore", 704 718 "crafting" 719 + ] 720 + } 721 + } 722 + ], 723 + "army": [ 724 + { 725 + "id": "deploy-army", 726 + "rollData": { 727 + "leader": "general", 728 + "skills": [ 729 + "nature", 730 + "survival", 731 + "athletics", 732 + "sailing-lore", 733 + "arcana", 734 + "nature", 735 + "occultism", 736 + "religion" 737 + ] 738 + } 739 + }, 740 + { 741 + "title": "turn.army.disband-army.title", 742 + "desc": "turn.army.disband-army.desc", 743 + "socketCallback": [ 744 + "disbandArmy" 745 + ] 746 + }, 747 + { 748 + "id": "garrison-army", 749 + "rollData": { 750 + "leader": "general", 751 + "skills": [ 752 + "warfare-lore", 753 + "crafting", 754 + "diplomacy", 755 + "deception", 756 + "society", 757 + "engineering-lore", 758 + "crafting" 759 + ] 760 + } 761 + }, 762 + { 763 + "id": "offensive-gambit", 764 + "rollData": { 765 + "leader": "general", 766 + "skills": [ 767 + "deception", 768 + "diplomacy", 769 + "society", 770 + "warfare-lore", 771 + "intimidation", 772 + "athletics" 773 + ] 774 + } 775 + }, 776 + { 777 + "id": "outfit-army", 778 + "rollData": { 779 + "leader": "any", 780 + "skills": [ 781 + "mercantile-lore", 782 + "society", 783 + "deception", 784 + "arcana", 785 + "nature", 786 + "occulitsm", 787 + "religion", 788 + "warfare-lore" 789 + ] 790 + } 791 + }, 792 + { 793 + "id": "recover-army", 794 + "rollData": { 795 + "leader": "general", 796 + "skills": [ 797 + "warfare-lore", 798 + "crafting", 799 + "arcana", 800 + "occultism", 801 + "society", 802 + "nature", 803 + "athletics", 804 + "performance", 805 + "intimidation", 806 + "religion" 807 + ] 808 + } 809 + }, 810 + { 811 + "id": "train-army", 812 + "rollData": { 813 + "leader": "general", 814 + "skills": [ 815 + "arcana", 816 + "occultism", 817 + "religion", 818 + "academia-lore", 819 + "warfare-lore", 820 + "intimidation", 821 + "athletics" 705 822 ] 706 823 } 707 824 }
+25 -4
src/svelte/tabs/turn.svelte
··· 187 187 188 188 function performRoll(event: Event): void { 189 189 const activityData = JSON.parse((event.target as HTMLElement).dataset.rollData!); 190 + console.log(activityData); 190 191 const phase: string = (event.target as HTMLElement).dataset.phase!; 191 192 const rollData = activityData.rollData; 192 - console.log(rollData); 193 - const leaderActor = (game as foundry.Game).actors.get(actor.getFlag("kingdom-homebrew", `leaders.${rollData.leader}`)); 193 + let leaderActor: string; 194 + 195 + if (rollData.leader === "any") { 196 + // Add dialog to choose leader 197 + } else { 198 + leaderActor = (game as foundry.Game).actors.get(actor.getFlag("kingdom-homebrew", `leaders.${rollData.leader}`)); 199 + } 194 200 195 201 const leaders: Record<string, string> = { 196 202 ruler: "loyalty", ··· 439 445 440 446 function showActivity(event: Event): void { 441 447 const target = event.target as HTMLHeadingElement; 442 - const div = target.parentElement.parentElement as HTMLDivElement; 448 + const div = target.parentElement!.parentElement as HTMLDivElement; 443 449 div.classList.toggle("collapsed"); 444 450 } 445 451 </script> ··· 529 535 </div> 530 536 {/each} 531 537 <h3>{kmLocalize("turns", "army")}</h3> 532 - <!--Army Activities--> 538 + {#each data.activities.army.sort(sortActivities) as activity} 539 + <div class="kmhb-activity collapsed"> 540 + {#if activity.id === undefined} 541 + <h4><span onclick={showActivity} onkeyup={() => {}} onkeydown={() => {}} role="none">{kmLocalize(activity.title)}</span></h4> 542 + <button onclick={(event: Event) => { 543 + activity.socketCallback.forEach((cb: string) => { 544 + callbacks[cb](event); 545 + }); 546 + }} title={kmLocalize(activity.title)} class="kmhb-action-button">{kmLocalize("perform")}</button> 547 + {:else} 548 + <h4><span onclick={showActivity} onkeyup={() => {}} onkeydown={() => {}} role="none">{kmLocalize("activities", activity.id, "title")}</span></h4> 549 + <button onclick={performRoll} data-roll-data={JSON.stringify({id: activity.id, rollData: activity.rollData})} data-phase="army" class="kmhb-action-button">{kmLocalize("check")} <i class="fa-solid fa-dice-d20"></i></button> 550 + <KingdomDesc actor={actor} activityData={activity} /> 551 + {/if} 552 + </div> 553 + {/each} 533 554 <h3>{kmLocalize("turns", "event")}</h3> 534 555 <!--Event Phase--> 535 556 <h3>{kmLocalize("turns", "xp")}</h3>