rpg-event-generator 1.3.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +507 -7
- package/demo.js +153 -4
- package/dist/index.js +394 -11
- package/package.json +16 -3
- package/scripts/event-economy.js +388 -0
- package/scripts/export-templates.js +289 -0
- package/scripts/generate-templates.js +407 -0
- package/templates/cyberpunk/event_100.json +43 -0
- package/templates/cyberpunk/event_11.json +42 -0
- package/templates/cyberpunk/event_14.json +42 -0
- package/templates/cyberpunk/event_15.json +43 -0
- package/templates/cyberpunk/event_16.json +43 -0
- package/templates/cyberpunk/event_18.json +44 -0
- package/templates/cyberpunk/event_2.json +42 -0
- package/templates/cyberpunk/event_26.json +42 -0
- package/templates/cyberpunk/event_27.json +43 -0
- package/templates/cyberpunk/event_3.json +43 -0
- package/templates/cyberpunk/event_30.json +42 -0
- package/templates/cyberpunk/event_32.json +42 -0
- package/templates/cyberpunk/event_36.json +43 -0
- package/templates/cyberpunk/event_37.json +42 -0
- package/templates/cyberpunk/event_39.json +42 -0
- package/templates/cyberpunk/event_4.json +42 -0
- package/templates/cyberpunk/event_40.json +42 -0
- package/templates/cyberpunk/event_42.json +43 -0
- package/templates/cyberpunk/event_46.json +43 -0
- package/templates/cyberpunk/event_49.json +44 -0
- package/templates/cyberpunk/event_5.json +44 -0
- package/templates/cyberpunk/event_50.json +42 -0
- package/templates/cyberpunk/event_51.json +42 -0
- package/templates/cyberpunk/event_54.json +43 -0
- package/templates/cyberpunk/event_55.json +44 -0
- package/templates/cyberpunk/event_57.json +42 -0
- package/templates/cyberpunk/event_58.json +42 -0
- package/templates/cyberpunk/event_61.json +43 -0
- package/templates/cyberpunk/event_62.json +43 -0
- package/templates/cyberpunk/event_64.json +42 -0
- package/templates/cyberpunk/event_65.json +42 -0
- package/templates/cyberpunk/event_66.json +42 -0
- package/templates/cyberpunk/event_68.json +43 -0
- package/templates/cyberpunk/event_69.json +43 -0
- package/templates/cyberpunk/event_71.json +42 -0
- package/templates/cyberpunk/event_72.json +42 -0
- package/templates/cyberpunk/event_73.json +42 -0
- package/templates/cyberpunk/event_74.json +42 -0
- package/templates/cyberpunk/event_75.json +44 -0
- package/templates/cyberpunk/event_76.json +43 -0
- package/templates/cyberpunk/event_78.json +43 -0
- package/templates/cyberpunk/event_79.json +42 -0
- package/templates/cyberpunk/event_8.json +42 -0
- package/templates/cyberpunk/event_80.json +43 -0
- package/templates/cyberpunk/event_81.json +43 -0
- package/templates/cyberpunk/event_83.json +44 -0
- package/templates/cyberpunk/event_84.json +43 -0
- package/templates/cyberpunk/event_86.json +44 -0
- package/templates/cyberpunk/event_88.json +43 -0
- package/templates/cyberpunk/event_9.json +42 -0
- package/templates/cyberpunk/event_91.json +42 -0
- package/templates/cyberpunk/event_92.json +43 -0
- package/templates/cyberpunk/event_93.json +42 -0
- package/templates/cyberpunk/event_95.json +42 -0
- package/templates/cyberpunk/event_96.json +43 -0
- package/templates/cyberpunk/event_97.json +43 -0
- package/templates/cyberpunk/event_98.json +42 -0
- package/templates/cyberpunk/event_99.json +42 -0
- package/templates/fantasy/event_1.json +44 -0
- package/templates/fantasy/event_10.json +43 -0
- package/templates/fantasy/event_11.json +43 -0
- package/templates/fantasy/event_12.json +42 -0
- package/templates/fantasy/event_13.json +43 -0
- package/templates/fantasy/event_16.json +44 -0
- package/templates/fantasy/event_20.json +42 -0
- package/templates/fantasy/event_21.json +42 -0
- package/templates/fantasy/event_22.json +42 -0
- package/templates/fantasy/event_23.json +42 -0
- package/templates/fantasy/event_24.json +43 -0
- package/templates/fantasy/event_27.json +43 -0
- package/templates/fantasy/event_29.json +43 -0
- package/templates/fantasy/event_3.json +42 -0
- package/templates/fantasy/event_30.json +43 -0
- package/templates/fantasy/event_31.json +42 -0
- package/templates/fantasy/event_33.json +42 -0
- package/templates/fantasy/event_34.json +43 -0
- package/templates/fantasy/event_36.json +43 -0
- package/templates/fantasy/event_38.json +43 -0
- package/templates/fantasy/event_39.json +42 -0
- package/templates/fantasy/event_4.json +44 -0
- package/templates/fantasy/event_41.json +43 -0
- package/templates/fantasy/event_44.json +42 -0
- package/templates/fantasy/event_45.json +42 -0
- package/templates/fantasy/event_46.json +42 -0
- package/templates/fantasy/event_47.json +42 -0
- package/templates/fantasy/event_48.json +42 -0
- package/templates/fantasy/event_5.json +42 -0
- package/templates/fantasy/event_50.json +44 -0
- package/templates/fantasy/event_51.json +43 -0
- package/templates/fantasy/event_54.json +43 -0
- package/templates/fantasy/event_55.json +43 -0
- package/templates/fantasy/event_57.json +44 -0
- package/templates/fantasy/event_58.json +44 -0
- package/templates/fantasy/event_6.json +42 -0
- package/templates/fantasy/event_64.json +42 -0
- package/templates/fantasy/event_68.json +42 -0
- package/templates/fantasy/event_69.json +43 -0
- package/templates/fantasy/event_70.json +42 -0
- package/templates/fantasy/event_71.json +42 -0
- package/templates/fantasy/event_72.json +43 -0
- package/templates/fantasy/event_73.json +42 -0
- package/templates/fantasy/event_76.json +43 -0
- package/templates/fantasy/event_77.json +43 -0
- package/templates/fantasy/event_79.json +42 -0
- package/templates/fantasy/event_88.json +42 -0
- package/templates/fantasy/event_9.json +44 -0
- package/templates/fantasy/event_90.json +43 -0
- package/templates/fantasy/event_91.json +42 -0
- package/templates/fantasy/event_92.json +42 -0
- package/templates/fantasy/event_94.json +43 -0
- package/templates/fantasy/event_96.json +42 -0
- package/templates/fantasy/event_97.json +42 -0
- package/templates/fantasy/event_98.json +42 -0
- package/templates/fantasy/event_99.json +42 -0
- package/templates/historical/event_1.json +44 -0
- package/templates/historical/event_10.json +42 -0
- package/templates/historical/event_11.json +44 -0
- package/templates/historical/event_14.json +44 -0
- package/templates/historical/event_17.json +44 -0
- package/templates/historical/event_2.json +43 -0
- package/templates/historical/event_20.json +43 -0
- package/templates/historical/event_21.json +44 -0
- package/templates/historical/event_22.json +43 -0
- package/templates/historical/event_25.json +43 -0
- package/templates/historical/event_26.json +42 -0
- package/templates/historical/event_3.json +43 -0
- package/templates/historical/event_30.json +42 -0
- package/templates/historical/event_33.json +44 -0
- package/templates/historical/event_34.json +42 -0
- package/templates/historical/event_39.json +42 -0
- package/templates/historical/event_4.json +44 -0
- package/templates/historical/event_40.json +42 -0
- package/templates/historical/event_42.json +42 -0
- package/templates/historical/event_44.json +43 -0
- package/templates/historical/event_45.json +43 -0
- package/templates/historical/event_48.json +42 -0
- package/templates/historical/event_50.json +42 -0
- package/templates/historical/event_52.json +42 -0
- package/templates/historical/event_53.json +44 -0
- package/templates/historical/event_54.json +44 -0
- package/templates/historical/event_56.json +42 -0
- package/templates/historical/event_57.json +42 -0
- package/templates/historical/event_59.json +42 -0
- package/templates/historical/event_60.json +43 -0
- package/templates/historical/event_61.json +42 -0
- package/templates/historical/event_62.json +44 -0
- package/templates/historical/event_63.json +42 -0
- package/templates/historical/event_64.json +43 -0
- package/templates/historical/event_65.json +44 -0
- package/templates/historical/event_66.json +42 -0
- package/templates/historical/event_67.json +43 -0
- package/templates/historical/event_69.json +43 -0
- package/templates/historical/event_7.json +42 -0
- package/templates/historical/event_70.json +42 -0
- package/templates/historical/event_71.json +43 -0
- package/templates/historical/event_74.json +42 -0
- package/templates/historical/event_75.json +43 -0
- package/templates/historical/event_79.json +42 -0
- package/templates/historical/event_8.json +44 -0
- package/templates/historical/event_80.json +43 -0
- package/templates/historical/event_82.json +42 -0
- package/templates/historical/event_87.json +43 -0
- package/templates/historical/event_89.json +43 -0
- package/templates/historical/event_9.json +43 -0
- package/templates/historical/event_90.json +44 -0
- package/templates/historical/event_91.json +42 -0
- package/templates/historical/event_92.json +43 -0
- package/templates/historical/event_94.json +42 -0
- package/templates/historical/event_97.json +42 -0
- package/templates/horror/event_1.json +42 -0
- package/templates/horror/event_100.json +42 -0
- package/templates/horror/event_12.json +42 -0
- package/templates/horror/event_13.json +43 -0
- package/templates/horror/event_14.json +44 -0
- package/templates/horror/event_15.json +42 -0
- package/templates/horror/event_16.json +43 -0
- package/templates/horror/event_17.json +43 -0
- package/templates/horror/event_18.json +42 -0
- package/templates/horror/event_2.json +44 -0
- package/templates/horror/event_20.json +43 -0
- package/templates/horror/event_23.json +42 -0
- package/templates/horror/event_27.json +43 -0
- package/templates/horror/event_28.json +42 -0
- package/templates/horror/event_29.json +42 -0
- package/templates/horror/event_3.json +42 -0
- package/templates/horror/event_30.json +42 -0
- package/templates/horror/event_32.json +42 -0
- package/templates/horror/event_34.json +42 -0
- package/templates/horror/event_35.json +43 -0
- package/templates/horror/event_36.json +43 -0
- package/templates/horror/event_37.json +43 -0
- package/templates/horror/event_38.json +44 -0
- package/templates/horror/event_39.json +42 -0
- package/templates/horror/event_40.json +42 -0
- package/templates/horror/event_41.json +42 -0
- package/templates/horror/event_42.json +43 -0
- package/templates/horror/event_43.json +43 -0
- package/templates/horror/event_45.json +42 -0
- package/templates/horror/event_46.json +44 -0
- package/templates/horror/event_47.json +42 -0
- package/templates/horror/event_50.json +43 -0
- package/templates/horror/event_52.json +44 -0
- package/templates/horror/event_53.json +43 -0
- package/templates/horror/event_55.json +43 -0
- package/templates/horror/event_56.json +44 -0
- package/templates/horror/event_58.json +42 -0
- package/templates/horror/event_59.json +42 -0
- package/templates/horror/event_60.json +43 -0
- package/templates/horror/event_61.json +44 -0
- package/templates/horror/event_62.json +42 -0
- package/templates/horror/event_63.json +43 -0
- package/templates/horror/event_65.json +42 -0
- package/templates/horror/event_67.json +43 -0
- package/templates/horror/event_68.json +44 -0
- package/templates/horror/event_72.json +42 -0
- package/templates/horror/event_73.json +44 -0
- package/templates/horror/event_74.json +43 -0
- package/templates/horror/event_77.json +42 -0
- package/templates/horror/event_79.json +43 -0
- package/templates/horror/event_8.json +42 -0
- package/templates/horror/event_82.json +43 -0
- package/templates/horror/event_83.json +42 -0
- package/templates/horror/event_84.json +42 -0
- package/templates/horror/event_86.json +43 -0
- package/templates/horror/event_88.json +42 -0
- package/templates/horror/event_89.json +43 -0
- package/templates/horror/event_9.json +43 -0
- package/templates/horror/event_90.json +44 -0
- package/templates/horror/event_91.json +43 -0
- package/templates/horror/event_93.json +42 -0
- package/templates/horror/event_95.json +42 -0
- package/templates/horror/event_96.json +43 -0
- package/templates/horror/event_99.json +42 -0
- package/templates/index.json +445 -5
- package/templates/modern/event_10.json +42 -0
- package/templates/modern/event_100.json +43 -0
- package/templates/modern/event_11.json +44 -0
- package/templates/modern/event_13.json +42 -0
- package/templates/modern/event_15.json +43 -0
- package/templates/modern/event_16.json +42 -0
- package/templates/modern/event_17.json +42 -0
- package/templates/modern/event_19.json +43 -0
- package/templates/modern/event_2.json +42 -0
- package/templates/modern/event_20.json +42 -0
- package/templates/modern/event_21.json +43 -0
- package/templates/modern/event_22.json +43 -0
- package/templates/modern/event_23.json +43 -0
- package/templates/modern/event_25.json +43 -0
- package/templates/modern/event_27.json +42 -0
- package/templates/modern/event_28.json +42 -0
- package/templates/modern/event_31.json +42 -0
- package/templates/modern/event_32.json +43 -0
- package/templates/modern/event_34.json +44 -0
- package/templates/modern/event_35.json +42 -0
- package/templates/modern/event_36.json +44 -0
- package/templates/modern/event_37.json +42 -0
- package/templates/modern/event_39.json +42 -0
- package/templates/modern/event_4.json +42 -0
- package/templates/modern/event_41.json +42 -0
- package/templates/modern/event_42.json +44 -0
- package/templates/modern/event_43.json +42 -0
- package/templates/modern/event_44.json +44 -0
- package/templates/modern/event_45.json +44 -0
- package/templates/modern/event_46.json +44 -0
- package/templates/modern/event_47.json +43 -0
- package/templates/modern/event_48.json +42 -0
- package/templates/modern/event_49.json +43 -0
- package/templates/modern/event_5.json +43 -0
- package/templates/modern/event_51.json +42 -0
- package/templates/modern/event_52.json +42 -0
- package/templates/modern/event_55.json +43 -0
- package/templates/modern/event_56.json +42 -0
- package/templates/modern/event_57.json +42 -0
- package/templates/modern/event_59.json +42 -0
- package/templates/modern/event_6.json +43 -0
- package/templates/modern/event_60.json +43 -0
- package/templates/modern/event_61.json +42 -0
- package/templates/modern/event_63.json +42 -0
- package/templates/modern/event_64.json +42 -0
- package/templates/modern/event_66.json +42 -0
- package/templates/modern/event_67.json +42 -0
- package/templates/modern/event_69.json +42 -0
- package/templates/modern/event_7.json +43 -0
- package/templates/modern/event_70.json +42 -0
- package/templates/modern/event_72.json +43 -0
- package/templates/modern/event_74.json +43 -0
- package/templates/modern/event_78.json +42 -0
- package/templates/modern/event_8.json +42 -0
- package/templates/modern/event_80.json +44 -0
- package/templates/modern/event_81.json +43 -0
- package/templates/modern/event_82.json +42 -0
- package/templates/modern/event_83.json +42 -0
- package/templates/modern/event_84.json +44 -0
- package/templates/modern/event_85.json +42 -0
- package/templates/modern/event_86.json +42 -0
- package/templates/modern/event_87.json +44 -0
- package/templates/modern/event_89.json +42 -0
- package/templates/modern/event_94.json +42 -0
- package/templates/modern/event_97.json +43 -0
- package/templates/modern/event_98.json +42 -0
- package/templates/modern/event_99.json +44 -0
- package/templates/schema.json +87 -0
- package/templates/sci-fi/event_1.json +42 -0
- package/templates/sci-fi/event_11.json +43 -0
- package/templates/sci-fi/event_13.json +43 -0
- package/templates/sci-fi/event_15.json +43 -0
- package/templates/sci-fi/event_18.json +42 -0
- package/templates/sci-fi/event_19.json +43 -0
- package/templates/sci-fi/event_2.json +44 -0
- package/templates/sci-fi/event_22.json +42 -0
- package/templates/sci-fi/event_23.json +42 -0
- package/templates/sci-fi/event_24.json +43 -0
- package/templates/sci-fi/event_25.json +42 -0
- package/templates/sci-fi/event_27.json +43 -0
- package/templates/sci-fi/event_28.json +43 -0
- package/templates/sci-fi/event_30.json +43 -0
- package/templates/sci-fi/event_31.json +42 -0
- package/templates/sci-fi/event_32.json +42 -0
- package/templates/sci-fi/event_33.json +44 -0
- package/templates/sci-fi/event_34.json +42 -0
- package/templates/sci-fi/event_35.json +42 -0
- package/templates/sci-fi/event_36.json +42 -0
- package/templates/sci-fi/event_37.json +44 -0
- package/templates/sci-fi/event_39.json +43 -0
- package/templates/sci-fi/event_4.json +43 -0
- package/templates/sci-fi/event_41.json +42 -0
- package/templates/sci-fi/event_45.json +42 -0
- package/templates/sci-fi/event_47.json +43 -0
- package/templates/sci-fi/event_48.json +42 -0
- package/templates/sci-fi/event_50.json +43 -0
- package/templates/sci-fi/event_51.json +42 -0
- package/templates/sci-fi/event_53.json +42 -0
- package/templates/sci-fi/event_54.json +43 -0
- package/templates/sci-fi/event_55.json +42 -0
- package/templates/sci-fi/event_56.json +43 -0
- package/templates/sci-fi/event_59.json +42 -0
- package/templates/sci-fi/event_6.json +42 -0
- package/templates/sci-fi/event_60.json +43 -0
- package/templates/sci-fi/event_64.json +44 -0
- package/templates/sci-fi/event_65.json +43 -0
- package/templates/sci-fi/event_67.json +42 -0
- package/templates/sci-fi/event_7.json +42 -0
- package/templates/sci-fi/event_72.json +42 -0
- package/templates/sci-fi/event_73.json +43 -0
- package/templates/sci-fi/event_74.json +44 -0
- package/templates/sci-fi/event_75.json +43 -0
- package/templates/sci-fi/event_78.json +42 -0
- package/templates/sci-fi/event_80.json +42 -0
- package/templates/sci-fi/event_82.json +43 -0
- package/templates/sci-fi/event_83.json +44 -0
- package/templates/sci-fi/event_85.json +42 -0
- package/templates/sci-fi/event_87.json +42 -0
- package/templates/sci-fi/event_89.json +42 -0
- package/templates/sci-fi/event_9.json +42 -0
- package/templates/sci-fi/event_90.json +43 -0
- package/templates/sci-fi/event_92.json +44 -0
- package/templates/sci-fi/event_93.json +42 -0
- package/templates/sci-fi/event_94.json +42 -0
- package/templates/sci-fi/event_95.json +43 -0
- package/templates/sci-fi/event_96.json +43 -0
- package/templates/sci-fi/event_97.json +42 -0
- package/templates/space-opera/event_1.json +44 -0
- package/templates/space-opera/event_10.json +42 -0
- package/templates/space-opera/event_100.json +42 -0
- package/templates/space-opera/event_12.json +42 -0
- package/templates/space-opera/event_13.json +44 -0
- package/templates/space-opera/event_14.json +43 -0
- package/templates/space-opera/event_15.json +43 -0
- package/templates/space-opera/event_17.json +42 -0
- package/templates/space-opera/event_18.json +43 -0
- package/templates/space-opera/event_19.json +42 -0
- package/templates/space-opera/event_20.json +43 -0
- package/templates/space-opera/event_21.json +42 -0
- package/templates/space-opera/event_24.json +44 -0
- package/templates/space-opera/event_25.json +42 -0
- package/templates/space-opera/event_26.json +43 -0
- package/templates/space-opera/event_27.json +43 -0
- package/templates/space-opera/event_28.json +43 -0
- package/templates/space-opera/event_29.json +44 -0
- package/templates/space-opera/event_31.json +42 -0
- package/templates/space-opera/event_32.json +42 -0
- package/templates/space-opera/event_33.json +42 -0
- package/templates/space-opera/event_35.json +42 -0
- package/templates/space-opera/event_36.json +44 -0
- package/templates/space-opera/event_38.json +43 -0
- package/templates/space-opera/event_40.json +42 -0
- package/templates/space-opera/event_41.json +42 -0
- package/templates/space-opera/event_43.json +43 -0
- package/templates/space-opera/event_44.json +42 -0
- package/templates/space-opera/event_47.json +42 -0
- package/templates/space-opera/event_48.json +43 -0
- package/templates/space-opera/event_49.json +44 -0
- package/templates/space-opera/event_5.json +44 -0
- package/templates/space-opera/event_50.json +42 -0
- package/templates/space-opera/event_51.json +42 -0
- package/templates/space-opera/event_52.json +42 -0
- package/templates/space-opera/event_53.json +43 -0
- package/templates/space-opera/event_55.json +42 -0
- package/templates/space-opera/event_58.json +43 -0
- package/templates/space-opera/event_6.json +43 -0
- package/templates/space-opera/event_60.json +44 -0
- package/templates/space-opera/event_61.json +42 -0
- package/templates/space-opera/event_62.json +43 -0
- package/templates/space-opera/event_65.json +42 -0
- package/templates/space-opera/event_67.json +42 -0
- package/templates/space-opera/event_68.json +43 -0
- package/templates/space-opera/event_69.json +42 -0
- package/templates/space-opera/event_7.json +44 -0
- package/templates/space-opera/event_71.json +44 -0
- package/templates/space-opera/event_73.json +42 -0
- package/templates/space-opera/event_74.json +42 -0
- package/templates/space-opera/event_77.json +43 -0
- package/templates/space-opera/event_78.json +43 -0
- package/templates/space-opera/event_8.json +43 -0
- package/templates/space-opera/event_81.json +42 -0
- package/templates/space-opera/event_82.json +42 -0
- package/templates/space-opera/event_83.json +43 -0
- package/templates/space-opera/event_85.json +42 -0
- package/templates/space-opera/event_87.json +42 -0
- package/templates/space-opera/event_88.json +42 -0
- package/templates/space-opera/event_90.json +42 -0
- package/templates/space-opera/event_93.json +43 -0
- package/templates/space-opera/event_97.json +42 -0
- package/templates/space-opera/event_98.json +43 -0
package/demo.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { RPGEventGenerator } = require('./dist/index.js');
|
|
4
4
|
|
|
5
5
|
const DEMO_CONFIG = {
|
|
6
|
-
version: '
|
|
6
|
+
version: '2.0.0',
|
|
7
7
|
showErrors: true,
|
|
8
8
|
pauseBetweenDemos: false
|
|
9
9
|
};
|
|
@@ -579,9 +579,158 @@ function runDemo() {
|
|
|
579
579
|
demoSystemStatus(enhancedGenerator);
|
|
580
580
|
demoAdvancedUsage(enhancedGenerator);
|
|
581
581
|
|
|
582
|
+
printHeader('🚀 v2.0.0 FEATURE DEMOS');
|
|
583
|
+
|
|
584
|
+
// v2.0.0 Feature Demos
|
|
585
|
+
demoCustomRuleEngine();
|
|
586
|
+
demoThemeCreator();
|
|
587
|
+
demoPureMarkovMode();
|
|
588
|
+
demoEventEconomy();
|
|
589
|
+
|
|
582
590
|
printHeader('✅ DEMO COMPLETE');
|
|
583
|
-
console.log('🎉 All
|
|
584
|
-
console.log('📦 Version
|
|
585
|
-
console.log('🚀
|
|
591
|
+
console.log('🎉 All v2.0.0 features demonstrated successfully!');
|
|
592
|
+
console.log('📦 Version 2.0.0 delivers revolutionary new capabilities with full backward compatibility.');
|
|
593
|
+
console.log('🚀 Production-ready for game development!');
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// v2.0.0 Feature Demos
|
|
597
|
+
function demoCustomRuleEngine() {
|
|
598
|
+
printSection('🧠 Demo 18: Custom Rule Engine (v2.0.0)');
|
|
599
|
+
|
|
600
|
+
const generator = new RPGEventGenerator({ enableRuleEngine: true });
|
|
601
|
+
|
|
602
|
+
// Create a custom rule for wealthy players
|
|
603
|
+
const wealthyRule = {
|
|
604
|
+
conditions: [
|
|
605
|
+
{ type: 'stat_greater_than', params: { stat: 'gold', value: 1000 } }
|
|
606
|
+
],
|
|
607
|
+
effects: {
|
|
608
|
+
modifyChoices: {
|
|
609
|
+
multiply: { gold: 1.3 },
|
|
610
|
+
add: { reputation: 5 }
|
|
611
|
+
},
|
|
612
|
+
addTags: ['wealthy_player_bonus']
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
safeExecute(() => {
|
|
617
|
+
generator.addCustomRule('wealthy_bonus', wealthyRule);
|
|
618
|
+
printResult('Rule added', 'wealthy_bonus');
|
|
619
|
+
|
|
620
|
+
// Test with wealthy player
|
|
621
|
+
const wealthyEvent = generator.generateEvent({ gold: 2000 });
|
|
622
|
+
printResult('Wealthy player event', wealthyEvent.title);
|
|
623
|
+
printResult('Tags applied', wealthyEvent.tags?.join(', ') || 'none');
|
|
624
|
+
|
|
625
|
+
// Test with poor player
|
|
626
|
+
const poorEvent = generator.generateEvent({ gold: 100 });
|
|
627
|
+
printResult('Poor player event', poorEvent.title);
|
|
628
|
+
printResult('Tags applied', poorEvent.tags?.join(', ') || 'none');
|
|
629
|
+
|
|
630
|
+
printResult('Active rules', Object.keys(generator.getCustomRules()).length);
|
|
631
|
+
}, 'custom rule engine');
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function demoThemeCreator() {
|
|
635
|
+
printSection('🎨 Demo 19: Theme Creator (v2.0.0)');
|
|
636
|
+
|
|
637
|
+
const customTrainingData = [
|
|
638
|
+
'Neon-lit cantinas pulse with quantum energy',
|
|
639
|
+
'Robotic bartenders serve drinks that change your memories',
|
|
640
|
+
'Space cowboys duel with laser revolvers under three moons',
|
|
641
|
+
'Alien merchants haggle over crystalline data cores',
|
|
642
|
+
'Floating colonies drift through asteroid fields'
|
|
643
|
+
];
|
|
644
|
+
|
|
645
|
+
safeExecute(() => {
|
|
646
|
+
const generator = new RPGEventGenerator({
|
|
647
|
+
trainingData: customTrainingData,
|
|
648
|
+
theme: 'space-opera',
|
|
649
|
+
culture: 'cyberpunk'
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
const event = generator.generateEvent();
|
|
653
|
+
printResult('Custom theme event', event.title);
|
|
654
|
+
printResult('Description preview', event.description.substring(0, 80) + '...');
|
|
655
|
+
printResult('Training sentences used', customTrainingData.length);
|
|
656
|
+
}, 'theme creator');
|
|
586
657
|
}
|
|
658
|
+
|
|
659
|
+
function demoPureMarkovMode() {
|
|
660
|
+
printSection('🎲 Demo 20: Pure Markov Mode (v2.0.0)');
|
|
661
|
+
|
|
662
|
+
const pureTrainingData = [
|
|
663
|
+
'Crystal caves echo with ancient magical resonances',
|
|
664
|
+
'Shadowy figures emerge from fog-shrouded forests',
|
|
665
|
+
'Forgotten ruins hide treasures and eldritch horrors',
|
|
666
|
+
'Mysterious merchants offer artifacts of power',
|
|
667
|
+
'Wandering bards sing tales of lost civilizations'
|
|
668
|
+
];
|
|
669
|
+
|
|
670
|
+
safeExecute(() => {
|
|
671
|
+
const pureGenerator = new RPGEventGenerator({
|
|
672
|
+
trainingData: pureTrainingData,
|
|
673
|
+
pureMarkovMode: true,
|
|
674
|
+
enableTemplates: false
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
const event = pureGenerator.generateEvent();
|
|
678
|
+
printResult('Pure Markov event', event.title);
|
|
679
|
+
printResult('Type', event.type);
|
|
680
|
+
printResult('Generated purely from', `${pureTrainingData.length} custom sentences`);
|
|
681
|
+
printResult('Templates disabled', 'true (Pure Markov only)');
|
|
682
|
+
}, 'pure Markov mode');
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
function demoEventEconomy() {
|
|
686
|
+
printSection('💰 Demo 21: Event Economy (v2.0.0)');
|
|
687
|
+
|
|
688
|
+
safeExecute(() => {
|
|
689
|
+
// Import the EventEconomy class
|
|
690
|
+
const EventEconomy = require('./scripts/event-economy');
|
|
691
|
+
|
|
692
|
+
// Create economy instance
|
|
693
|
+
const economy = new EventEconomy('./user-content');
|
|
694
|
+
|
|
695
|
+
// Create a sample theme
|
|
696
|
+
const sampleTheme = {
|
|
697
|
+
name: 'CyberWestern',
|
|
698
|
+
author: 'DemoCreator',
|
|
699
|
+
description: 'Cyberpunk western theme',
|
|
700
|
+
tags: ['cyberpunk', 'western', 'scifi'],
|
|
701
|
+
settings: {
|
|
702
|
+
theme: 'cyberpunk',
|
|
703
|
+
culture: 'western',
|
|
704
|
+
enableRuleEngine: true
|
|
705
|
+
},
|
|
706
|
+
trainingData: [
|
|
707
|
+
'neon signs flicker in the dusty saloon',
|
|
708
|
+
'robotic sheriffs maintain order',
|
|
709
|
+
'cyborg outlaws ride mechanical horses'
|
|
710
|
+
],
|
|
711
|
+
customRules: [],
|
|
712
|
+
statistics: {
|
|
713
|
+
trainingSentences: 3,
|
|
714
|
+
estimatedQuality: 75
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
|
|
718
|
+
// Save the theme
|
|
719
|
+
const themePath = economy.saveTheme('CyberWestern', sampleTheme);
|
|
720
|
+
printResult('Theme saved to', themePath);
|
|
721
|
+
|
|
722
|
+
// Load the theme
|
|
723
|
+
const loadedTheme = economy.loadTheme('CyberWestern');
|
|
724
|
+
printResult('Theme loaded', loadedTheme.name);
|
|
725
|
+
printResult('Author', loadedTheme.author);
|
|
726
|
+
printResult('Training sentences', loadedTheme.trainingData.length);
|
|
727
|
+
|
|
728
|
+
// Show statistics
|
|
729
|
+
const stats = economy.getStatistics();
|
|
730
|
+
printResult('Total themes saved', stats.totalThemes);
|
|
731
|
+
printResult('Total quality score', Math.round(stats.averageThemeQuality) + '/100');
|
|
732
|
+
|
|
733
|
+
}, 'event economy');
|
|
734
|
+
}
|
|
735
|
+
|
|
587
736
|
runDemo();
|
package/dist/index.js
CHANGED
|
@@ -118,6 +118,7 @@ class RPGEventGenerator {
|
|
|
118
118
|
/**
|
|
119
119
|
* Create a new event generator
|
|
120
120
|
* @param {Object} options - Configuration options
|
|
121
|
+
* @param {Chance} options.chance - Chance.js instance (optional, will create new if not provided)
|
|
121
122
|
* @param {number} options.stateSize - Markov chain state size (default: 2)
|
|
122
123
|
* @param {Array} options.trainingData - Custom training data for Markov chains
|
|
123
124
|
* @param {string} options.theme - Theme for event generation: 'fantasy', 'sci-fi', 'historical'
|
|
@@ -126,11 +127,11 @@ class RPGEventGenerator {
|
|
|
126
127
|
* @param {string} options.templateLibrary - Genre to load templates from: 'fantasy', 'sci-fi', 'horror', 'historical'
|
|
127
128
|
*/
|
|
128
129
|
constructor(options = {}) {
|
|
129
|
-
this.chance = new Chance();
|
|
130
|
+
this.chance = options.chance || new Chance();
|
|
130
131
|
this.markovGenerator = new SimpleMarkovGenerator({
|
|
131
132
|
stateSize: options.stateSize || 2
|
|
132
133
|
});
|
|
133
|
-
this.theme = options.theme
|
|
134
|
+
this.theme = options.theme !== undefined ? options.theme : 'fantasy';
|
|
134
135
|
this.culture = options.culture;
|
|
135
136
|
this.customTemplates = new Set();
|
|
136
137
|
this.customChains = new Set();
|
|
@@ -139,9 +140,14 @@ class RPGEventGenerator {
|
|
|
139
140
|
this.enableModifiers = options.enableModifiers !== false;
|
|
140
141
|
this.enableRelationships = options.enableRelationships !== false;
|
|
141
142
|
this.language = options.language || 'en';
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
143
|
+
this.pureMarkovMode = options.pureMarkovMode || false;
|
|
144
|
+
this.enableTemplates = this.pureMarkovMode ? false : options.enableTemplates !== false;
|
|
145
|
+
this.templateLibrary = this.pureMarkovMode ? null : options.templateLibrary || null;
|
|
144
146
|
this.loadedTemplates = new Map();
|
|
147
|
+
this.enableRuleEngine = options.enableRuleEngine !== false;
|
|
148
|
+
this.customRules = options.customRules || {};
|
|
149
|
+
this.ruleEngine = this.initializeRuleEngine();
|
|
150
|
+
this.pureMarkovMode = options.pureMarkovMode || false;
|
|
145
151
|
this.initializeEnhancedFeatures(options);
|
|
146
152
|
this.initializeTemplateSystem(options);
|
|
147
153
|
this.initializeThemes();
|
|
@@ -934,6 +940,139 @@ class RPGEventGenerator {
|
|
|
934
940
|
*/
|
|
935
941
|
generateEvent(playerContext = {}) {
|
|
936
942
|
const context = this.analyzeContext(playerContext);
|
|
943
|
+
let event;
|
|
944
|
+
if (this.pureMarkovMode) {
|
|
945
|
+
event = this.generatePureMarkovEvent(context);
|
|
946
|
+
} else {
|
|
947
|
+
const template = this.selectTemplate(context);
|
|
948
|
+
const scaledChoices = this.scaleEffectsForDifficulty(this.generateContextualChoices(template.choices, context), context);
|
|
949
|
+
event = {
|
|
950
|
+
id: `event_${Date.now()}_${this.chance.guid().substring(0, 8)}`,
|
|
951
|
+
title: this.generateDynamicTitle(template, context),
|
|
952
|
+
description: this.generateRichDescription(template, context),
|
|
953
|
+
narrative: template.narrative,
|
|
954
|
+
choices: scaledChoices,
|
|
955
|
+
type: Object.keys(this.templates).find(key => this.templates[key] === template),
|
|
956
|
+
consequence: null,
|
|
957
|
+
context: context,
|
|
958
|
+
urgency: this.calculateUrgency(template, context),
|
|
959
|
+
theme: this.determineTheme(template, context),
|
|
960
|
+
difficulty: this.calculateDifficultyTier(context.power_level || 0),
|
|
961
|
+
tags: template.tags || []
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// Apply custom rules if rule engine is enabled
|
|
966
|
+
if (this.enableRuleEngine) {
|
|
967
|
+
event = this.applyCustomRules(event, context);
|
|
968
|
+
}
|
|
969
|
+
return event;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Generate an event purely from Markov chains (v2.0.0)
|
|
974
|
+
* @param {Object} context - Generation context
|
|
975
|
+
* @returns {Object} Generated event
|
|
976
|
+
*/
|
|
977
|
+
generatePureMarkovEvent(context) {
|
|
978
|
+
try {
|
|
979
|
+
const titleGenerated = this.markovGenerator.generate({
|
|
980
|
+
minLength: 15,
|
|
981
|
+
maxLength: 40,
|
|
982
|
+
maxTries: 10
|
|
983
|
+
});
|
|
984
|
+
let title = titleGenerated && titleGenerated.string ? titleGenerated.string.trim().charAt(0).toUpperCase() + titleGenerated.string.trim().slice(1) : 'Mysterious Occurrence';
|
|
985
|
+
if (title.length > 35) {
|
|
986
|
+
title = title.substring(0, 32) + '...';
|
|
987
|
+
}
|
|
988
|
+
const narrativeGenerated = this.markovGenerator.generate({
|
|
989
|
+
minLength: 50,
|
|
990
|
+
maxLength: 120,
|
|
991
|
+
maxTries: 15
|
|
992
|
+
});
|
|
993
|
+
const narrative = narrativeGenerated && narrativeGenerated.string ? narrativeGenerated.string : 'Something extraordinary has occurred that demands your attention.';
|
|
994
|
+
const descriptionGenerated = this.markovGenerator.generate({
|
|
995
|
+
minLength: 30,
|
|
996
|
+
maxLength: 80,
|
|
997
|
+
maxTries: 10
|
|
998
|
+
});
|
|
999
|
+
let description = narrative;
|
|
1000
|
+
if (descriptionGenerated && descriptionGenerated.string && descriptionGenerated.string.length > 20) {
|
|
1001
|
+
description = descriptionGenerated.string + '. ' + narrative.charAt(0).toLowerCase() + narrative.slice(1);
|
|
1002
|
+
}
|
|
1003
|
+
const choices = this.generateMarkovChoices(context);
|
|
1004
|
+
return {
|
|
1005
|
+
id: `event_${Date.now()}_${this.chance.guid().substring(0, 8)}`,
|
|
1006
|
+
title: title,
|
|
1007
|
+
description: description,
|
|
1008
|
+
narrative: narrative,
|
|
1009
|
+
choices: choices,
|
|
1010
|
+
type: 'MARKOV_GENERATED',
|
|
1011
|
+
consequence: null,
|
|
1012
|
+
context: context,
|
|
1013
|
+
urgency: 'normal',
|
|
1014
|
+
theme: 'custom',
|
|
1015
|
+
difficulty: this.calculateDifficultyTier(context.power_level || 0),
|
|
1016
|
+
tags: []
|
|
1017
|
+
};
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
console.warn('Pure Markov generation failed, falling back to template:', error.message);
|
|
1020
|
+
return this.generateTemplateBasedEvent(context);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Generate choices for pure Markov events
|
|
1026
|
+
* @param {Object} context - Generation context
|
|
1027
|
+
* @returns {Array} Generated choices
|
|
1028
|
+
*/
|
|
1029
|
+
generateMarkovChoices(context) {
|
|
1030
|
+
const choiceTemplates = ['Embrace this opportunity and see where it leads', 'Approach cautiously and assess the situation', 'Seek advice from others before proceeding', 'Take immediate action to resolve the matter', 'Observe and learn from this experience', 'Decline involvement and move on', 'Investigate further to understand better', 'Trust your instincts and follow your heart'];
|
|
1031
|
+
const numChoices = this.chance.integer({
|
|
1032
|
+
min: 2,
|
|
1033
|
+
max: 4
|
|
1034
|
+
});
|
|
1035
|
+
const selectedChoices = this.chance.pickset(choiceTemplates, numChoices);
|
|
1036
|
+
return selectedChoices.map((text, index) => {
|
|
1037
|
+
const effects = {};
|
|
1038
|
+
if (this.chance.bool({
|
|
1039
|
+
likelihood: 60
|
|
1040
|
+
})) {
|
|
1041
|
+
effects.gold = this.chance.integer({
|
|
1042
|
+
min: -50,
|
|
1043
|
+
max: 100
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
if (this.chance.bool({
|
|
1047
|
+
likelihood: 40
|
|
1048
|
+
})) {
|
|
1049
|
+
effects.reputation = this.chance.integer({
|
|
1050
|
+
min: -10,
|
|
1051
|
+
max: 20
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
if (this.chance.bool({
|
|
1055
|
+
likelihood: 30
|
|
1056
|
+
})) {
|
|
1057
|
+
effects.knowledge = this.chance.integer({
|
|
1058
|
+
min: 5,
|
|
1059
|
+
max: 25
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
return {
|
|
1063
|
+
text: text,
|
|
1064
|
+
effect: effects,
|
|
1065
|
+
consequence: `markov_choice_${index}`
|
|
1066
|
+
};
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Fallback method for pure Markov generation failures
|
|
1072
|
+
* @param {Object} context - Generation context
|
|
1073
|
+
* @returns {Object} Generated event
|
|
1074
|
+
*/
|
|
1075
|
+
generateTemplateBasedEvent(context) {
|
|
937
1076
|
const template = this.selectTemplate(context);
|
|
938
1077
|
const scaledChoices = this.scaleEffectsForDifficulty(this.generateContextualChoices(template.choices, context), context);
|
|
939
1078
|
return {
|
|
@@ -951,6 +1090,96 @@ class RPGEventGenerator {
|
|
|
951
1090
|
};
|
|
952
1091
|
}
|
|
953
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* Apply custom rules to an event (v2.0.0)
|
|
1095
|
+
* @param {Object} event - The generated event
|
|
1096
|
+
* @param {Object} context - The generation context
|
|
1097
|
+
* @returns {Object} Modified event with rules applied
|
|
1098
|
+
*/
|
|
1099
|
+
applyCustomRules(event, context) {
|
|
1100
|
+
let modifiedEvent = event;
|
|
1101
|
+
for (const [ruleName, rule] of Object.entries(this.customRules)) {
|
|
1102
|
+
if (this.ruleEngine.evaluateRule(context, rule)) {
|
|
1103
|
+
modifiedEvent = this.ruleEngine.applyRuleEffects(modifiedEvent, rule, context);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
return modifiedEvent;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Add a custom rule to the rule engine (v2.0.0)
|
|
1111
|
+
* @param {string} name - Unique rule name
|
|
1112
|
+
* @param {Object} rule - Rule definition
|
|
1113
|
+
* @param {Array} rule.conditions - Array of condition objects
|
|
1114
|
+
* @param {Object} rule.effects - Effects to apply when conditions are met
|
|
1115
|
+
*/
|
|
1116
|
+
addCustomRule(name, rule) {
|
|
1117
|
+
this.customRules[name] = rule;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Remove a custom rule (v2.0.0)
|
|
1122
|
+
* @param {string} name - Rule name to remove
|
|
1123
|
+
*/
|
|
1124
|
+
removeCustomRule(name) {
|
|
1125
|
+
if (this.customRules[name]) {
|
|
1126
|
+
delete this.customRules[name];
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Get all custom rules (v2.0.0)
|
|
1132
|
+
* @returns {Object} All custom rules
|
|
1133
|
+
*/
|
|
1134
|
+
getCustomRules() {
|
|
1135
|
+
return {
|
|
1136
|
+
...this.customRules
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Clear all custom rules (v2.0.0)
|
|
1142
|
+
*/
|
|
1143
|
+
clearCustomRules() {
|
|
1144
|
+
this.customRules = {};
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* Validate a custom rule definition (v2.0.0)
|
|
1149
|
+
* @param {Object} rule - Rule to validate
|
|
1150
|
+
* @returns {Object} Validation result { valid: boolean, errors: Array }
|
|
1151
|
+
*/
|
|
1152
|
+
validateCustomRule(rule) {
|
|
1153
|
+
const errors = [];
|
|
1154
|
+
if (!rule || typeof rule !== 'object') {
|
|
1155
|
+
errors.push('Rule must be an object');
|
|
1156
|
+
return {
|
|
1157
|
+
valid: false,
|
|
1158
|
+
errors
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
if (rule.conditions && !Array.isArray(rule.conditions)) {
|
|
1162
|
+
errors.push('Conditions must be an array');
|
|
1163
|
+
}
|
|
1164
|
+
if (rule.effects && typeof rule.effects !== 'object') {
|
|
1165
|
+
errors.push('Effects must be an object');
|
|
1166
|
+
}
|
|
1167
|
+
if (rule.conditions && Array.isArray(rule.conditions)) {
|
|
1168
|
+
rule.conditions.forEach((condition, index) => {
|
|
1169
|
+
if (!condition.type) {
|
|
1170
|
+
errors.push(`Condition ${index} missing type`);
|
|
1171
|
+
}
|
|
1172
|
+
if (!this.ruleEngine.conditionEvaluators[condition.type]) {
|
|
1173
|
+
errors.push(`Condition ${index} has unknown type: ${condition.type}`);
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
valid: errors.length === 0,
|
|
1179
|
+
errors
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
|
|
954
1183
|
/**
|
|
955
1184
|
* Generate multiple events at once
|
|
956
1185
|
* @param {Object} playerContext - Player stats and state
|
|
@@ -988,6 +1217,163 @@ class RPGEventGenerator {
|
|
|
988
1217
|
this.initializeRelationshipRules();
|
|
989
1218
|
}
|
|
990
1219
|
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* Initialize the custom rule engine system (v2.0.0)
|
|
1223
|
+
*/
|
|
1224
|
+
initializeRuleEngine() {
|
|
1225
|
+
const ruleEngine = {
|
|
1226
|
+
rules: new Map(),
|
|
1227
|
+
evaluators: new Map(),
|
|
1228
|
+
conditions: new Map(),
|
|
1229
|
+
conditionEvaluators: {},
|
|
1230
|
+
evaluateCondition: function (context, condition) {
|
|
1231
|
+
const evaluator = this.conditionEvaluators[condition.type];
|
|
1232
|
+
if (!evaluator) {
|
|
1233
|
+
console.warn(`Unknown condition type: ${condition.type}`);
|
|
1234
|
+
return false;
|
|
1235
|
+
}
|
|
1236
|
+
return evaluator(context, condition.params || {}, this);
|
|
1237
|
+
},
|
|
1238
|
+
initializeConditionEvaluators: function () {
|
|
1239
|
+
const self = this;
|
|
1240
|
+
this.conditionEvaluators = {
|
|
1241
|
+
stat_greater_than: (context, params) => {
|
|
1242
|
+
var _context$player;
|
|
1243
|
+
const stat = ((_context$player = context.player) === null || _context$player === void 0 ? void 0 : _context$player[params.stat]) || context[params.stat] || 0;
|
|
1244
|
+
return stat > params.value;
|
|
1245
|
+
},
|
|
1246
|
+
stat_less_than: (context, params) => {
|
|
1247
|
+
var _context$player2;
|
|
1248
|
+
const stat = ((_context$player2 = context.player) === null || _context$player2 === void 0 ? void 0 : _context$player2[params.stat]) || context[params.stat] || 0;
|
|
1249
|
+
return stat < params.value;
|
|
1250
|
+
},
|
|
1251
|
+
stat_between: (context, params) => {
|
|
1252
|
+
var _context$player3;
|
|
1253
|
+
const stat = ((_context$player3 = context.player) === null || _context$player3 === void 0 ? void 0 : _context$player3[params.stat]) || context[params.stat] || 0;
|
|
1254
|
+
return stat >= params.min && stat <= params.max;
|
|
1255
|
+
},
|
|
1256
|
+
has_item: (context, params) => {
|
|
1257
|
+
var _context$player4;
|
|
1258
|
+
return ((_context$player4 = context.player) === null || _context$player4 === void 0 || (_context$player4 = _context$player4.inventory) === null || _context$player4 === void 0 ? void 0 : _context$player4.includes(params.item)) || false;
|
|
1259
|
+
},
|
|
1260
|
+
location_is: (context, params) => {
|
|
1261
|
+
return context.location === params.location;
|
|
1262
|
+
},
|
|
1263
|
+
season_is: (context, params) => {
|
|
1264
|
+
return context.season === params.season;
|
|
1265
|
+
},
|
|
1266
|
+
career_is: (context, params) => {
|
|
1267
|
+
var _context$player5;
|
|
1268
|
+
return (((_context$player5 = context.player) === null || _context$player5 === void 0 ? void 0 : _context$player5.career) || context.career) === params.career;
|
|
1269
|
+
},
|
|
1270
|
+
time_greater_than: (context, params) => {
|
|
1271
|
+
var _context$time;
|
|
1272
|
+
return (((_context$time = context.time) === null || _context$time === void 0 ? void 0 : _context$time.day) || 0) > params.days;
|
|
1273
|
+
},
|
|
1274
|
+
relationship_status: (context, params) => {
|
|
1275
|
+
var _context$relationship;
|
|
1276
|
+
const relationship = (_context$relationship = context.relationships) === null || _context$relationship === void 0 ? void 0 : _context$relationship.find(r => r.name === params.npc);
|
|
1277
|
+
if (!relationship) return false;
|
|
1278
|
+
return relationship.relationship >= params.min && relationship.relationship <= params.max;
|
|
1279
|
+
},
|
|
1280
|
+
random_chance: (context, params) => {
|
|
1281
|
+
return Math.random() < params.probability;
|
|
1282
|
+
},
|
|
1283
|
+
and: (context, params, ruleEngine) => {
|
|
1284
|
+
return params.conditions.every(condition => ruleEngine.evaluateCondition(context, condition));
|
|
1285
|
+
},
|
|
1286
|
+
or: (context, params, ruleEngine) => {
|
|
1287
|
+
return params.conditions.some(condition => ruleEngine.evaluateCondition(context, condition));
|
|
1288
|
+
},
|
|
1289
|
+
not: (context, params, ruleEngine) => {
|
|
1290
|
+
return !ruleEngine.evaluateCondition(context, params.condition);
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
},
|
|
1294
|
+
evaluateRule: function (context, rule) {
|
|
1295
|
+
if (!rule.conditions || rule.conditions.length === 0) {
|
|
1296
|
+
return true;
|
|
1297
|
+
}
|
|
1298
|
+
return rule.conditions.every(condition => this.evaluateCondition(context, condition));
|
|
1299
|
+
},
|
|
1300
|
+
applyRuleEffects: function (event, rule, context) {
|
|
1301
|
+
if (!rule.effects) return event;
|
|
1302
|
+
const modifiedEvent = JSON.parse(JSON.stringify(event));
|
|
1303
|
+
if (rule.effects.modifyChoices) {
|
|
1304
|
+
modifiedEvent.choices = modifiedEvent.choices.map(choice => ({
|
|
1305
|
+
...choice,
|
|
1306
|
+
effect: this.applyEffectModifiers(choice.effect, rule.effects.modifyChoices, context)
|
|
1307
|
+
}));
|
|
1308
|
+
}
|
|
1309
|
+
if (rule.effects.addChoices) {
|
|
1310
|
+
modifiedEvent.choices = [...modifiedEvent.choices, ...rule.effects.addChoices];
|
|
1311
|
+
}
|
|
1312
|
+
if (rule.effects.modifyTitle) {
|
|
1313
|
+
modifiedEvent.title = this.applyTextModifiers(modifiedEvent.title, rule.effects.modifyTitle, context);
|
|
1314
|
+
}
|
|
1315
|
+
if (rule.effects.modifyNarrative) {
|
|
1316
|
+
modifiedEvent.narrative = this.applyTextModifiers(modifiedEvent.narrative, rule.effects.modifyNarrative, context);
|
|
1317
|
+
}
|
|
1318
|
+
if (rule.effects.setDifficulty) {
|
|
1319
|
+
modifiedEvent.difficulty = rule.effects.setDifficulty;
|
|
1320
|
+
}
|
|
1321
|
+
if (rule.effects.addTags) {
|
|
1322
|
+
if (!modifiedEvent.tags) modifiedEvent.tags = [];
|
|
1323
|
+
modifiedEvent.tags = [...modifiedEvent.tags, ...rule.effects.addTags];
|
|
1324
|
+
}
|
|
1325
|
+
return modifiedEvent;
|
|
1326
|
+
},
|
|
1327
|
+
applyEffectModifiers: function (effect, modifiers, context) {
|
|
1328
|
+
const modified = {
|
|
1329
|
+
...effect
|
|
1330
|
+
};
|
|
1331
|
+
if (modifiers.multiply) {
|
|
1332
|
+
Object.keys(modifiers.multiply).forEach(key => {
|
|
1333
|
+
if (modified[key] !== undefined) {
|
|
1334
|
+
if (Array.isArray(modified[key])) {
|
|
1335
|
+
modified[key] = modified[key].map(val => Math.round(val * modifiers.multiply[key]));
|
|
1336
|
+
} else {
|
|
1337
|
+
modified[key] = Math.round(modified[key] * modifiers.multiply[key]);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
if (modifiers.add) {
|
|
1343
|
+
Object.keys(modifiers.add).forEach(key => {
|
|
1344
|
+
if (modified[key] !== undefined) {
|
|
1345
|
+
if (Array.isArray(modified[key])) {
|
|
1346
|
+
modified[key] = modified[key].map(val => val + modifiers.add[key]);
|
|
1347
|
+
} else {
|
|
1348
|
+
modified[key] = modified[key] + modifiers.add[key];
|
|
1349
|
+
}
|
|
1350
|
+
} else {
|
|
1351
|
+
modified[key] = modifiers.add[key];
|
|
1352
|
+
}
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
return modified;
|
|
1356
|
+
},
|
|
1357
|
+
applyTextModifiers: function (text, modifiers, context) {
|
|
1358
|
+
let modifiedText = text;
|
|
1359
|
+
if (modifiers.replace) {
|
|
1360
|
+
Object.keys(modifiers.replace).forEach(pattern => {
|
|
1361
|
+
const replacement = modifiers.replace[pattern];
|
|
1362
|
+
modifiedText = modifiedText.replace(new RegExp(pattern, 'g'), replacement);
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
if (modifiers.append) {
|
|
1366
|
+
modifiedText += modifiers.append;
|
|
1367
|
+
}
|
|
1368
|
+
if (modifiers.prepend) {
|
|
1369
|
+
modifiedText = modifiers.prepend + modifiedText;
|
|
1370
|
+
}
|
|
1371
|
+
return modifiedText;
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
ruleEngine.initializeConditionEvaluators();
|
|
1375
|
+
return ruleEngine;
|
|
1376
|
+
}
|
|
991
1377
|
initializeTemplateSystem(options) {
|
|
992
1378
|
if (this.enableTemplates && this.templateLibrary) {
|
|
993
1379
|
try {
|
|
@@ -1022,7 +1408,6 @@ class RPGEventGenerator {
|
|
|
1022
1408
|
}
|
|
1023
1409
|
}
|
|
1024
1410
|
});
|
|
1025
|
-
console.log(`Loaded ${loadedCount} templates from ${genre} library`);
|
|
1026
1411
|
} catch (error) {
|
|
1027
1412
|
console.warn('Template loading failed:', error.message);
|
|
1028
1413
|
}
|
|
@@ -1468,7 +1853,7 @@ class RPGEventGenerator {
|
|
|
1468
1853
|
template: this.templates[stage.template]
|
|
1469
1854
|
};
|
|
1470
1855
|
triggeredEvents.push(event);
|
|
1471
|
-
break;
|
|
1856
|
+
break;
|
|
1472
1857
|
}
|
|
1473
1858
|
}
|
|
1474
1859
|
}
|
|
@@ -1519,7 +1904,6 @@ class RPGEventGenerator {
|
|
|
1519
1904
|
day: this.timeSystem.currentDay,
|
|
1520
1905
|
season: this.timeSystem.currentSeason,
|
|
1521
1906
|
year: Math.ceil(this.timeSystem.currentDay / 360),
|
|
1522
|
-
// Roughly 360 days per year
|
|
1523
1907
|
seasonalModifiers: ((_this$seasonalEvents$ = this.seasonalEvents[this.timeSystem.currentSeason]) === null || _this$seasonalEvents$ === void 0 ? void 0 : _this$seasonalEvents$.modifiers) || {}
|
|
1524
1908
|
};
|
|
1525
1909
|
}
|
|
@@ -2104,8 +2488,7 @@ class RPGEventGenerator {
|
|
|
2104
2488
|
};
|
|
2105
2489
|
Object.keys(adjustedWeights).forEach(templateKey => {
|
|
2106
2490
|
const rating = challengeRatings[templateKey] || 5;
|
|
2107
|
-
const powerRatio = powerLevel / 100;
|
|
2108
|
-
|
|
2491
|
+
const powerRatio = powerLevel / 100;
|
|
2109
2492
|
if (rating < powerRatio + 2) {
|
|
2110
2493
|
adjustedWeights[templateKey] *= 0.5;
|
|
2111
2494
|
} else if (rating >= powerRatio + 2 && rating <= powerRatio + 5) {
|
|
@@ -2448,7 +2831,7 @@ class RPGEventGenerator {
|
|
|
2448
2831
|
break;
|
|
2449
2832
|
case 'stress':
|
|
2450
2833
|
case 'happiness':
|
|
2451
|
-
if (context.age > 40) multiplier *= 1.1;
|
|
2834
|
+
if (context.age > 40) multiplier *= 1.1;
|
|
2452
2835
|
break;
|
|
2453
2836
|
}
|
|
2454
2837
|
return multiplier;
|
|
@@ -3171,7 +3554,7 @@ class RPGEventGenerator {
|
|
|
3171
3554
|
*/
|
|
3172
3555
|
getSystemStatus() {
|
|
3173
3556
|
return {
|
|
3174
|
-
version: '
|
|
3557
|
+
version: '2.0.0',
|
|
3175
3558
|
language: this.language,
|
|
3176
3559
|
availableLanguages: Array.from(this.locales.keys()),
|
|
3177
3560
|
modifiersEnabled: this.enableModifiers,
|