rpg-event-generator 1.3.0 → 2.0.0
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 +491 -7
- package/demo.js +153 -4
- package/dist/index.js +392 -10
- 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
|
@@ -130,7 +130,7 @@ class RPGEventGenerator {
|
|
|
130
130
|
this.markovGenerator = new SimpleMarkovGenerator({
|
|
131
131
|
stateSize: options.stateSize || 2
|
|
132
132
|
});
|
|
133
|
-
this.theme = options.theme
|
|
133
|
+
this.theme = options.theme !== undefined ? options.theme : 'fantasy';
|
|
134
134
|
this.culture = options.culture;
|
|
135
135
|
this.customTemplates = new Set();
|
|
136
136
|
this.customChains = new Set();
|
|
@@ -139,9 +139,14 @@ class RPGEventGenerator {
|
|
|
139
139
|
this.enableModifiers = options.enableModifiers !== false;
|
|
140
140
|
this.enableRelationships = options.enableRelationships !== false;
|
|
141
141
|
this.language = options.language || 'en';
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
142
|
+
this.pureMarkovMode = options.pureMarkovMode || false;
|
|
143
|
+
this.enableTemplates = this.pureMarkovMode ? false : options.enableTemplates !== false;
|
|
144
|
+
this.templateLibrary = this.pureMarkovMode ? null : options.templateLibrary || null;
|
|
144
145
|
this.loadedTemplates = new Map();
|
|
146
|
+
this.enableRuleEngine = options.enableRuleEngine !== false;
|
|
147
|
+
this.customRules = options.customRules || {};
|
|
148
|
+
this.ruleEngine = this.initializeRuleEngine();
|
|
149
|
+
this.pureMarkovMode = options.pureMarkovMode || false;
|
|
145
150
|
this.initializeEnhancedFeatures(options);
|
|
146
151
|
this.initializeTemplateSystem(options);
|
|
147
152
|
this.initializeThemes();
|
|
@@ -934,6 +939,139 @@ class RPGEventGenerator {
|
|
|
934
939
|
*/
|
|
935
940
|
generateEvent(playerContext = {}) {
|
|
936
941
|
const context = this.analyzeContext(playerContext);
|
|
942
|
+
let event;
|
|
943
|
+
if (this.pureMarkovMode) {
|
|
944
|
+
event = this.generatePureMarkovEvent(context);
|
|
945
|
+
} else {
|
|
946
|
+
const template = this.selectTemplate(context);
|
|
947
|
+
const scaledChoices = this.scaleEffectsForDifficulty(this.generateContextualChoices(template.choices, context), context);
|
|
948
|
+
event = {
|
|
949
|
+
id: `event_${Date.now()}_${this.chance.guid().substring(0, 8)}`,
|
|
950
|
+
title: this.generateDynamicTitle(template, context),
|
|
951
|
+
description: this.generateRichDescription(template, context),
|
|
952
|
+
narrative: template.narrative,
|
|
953
|
+
choices: scaledChoices,
|
|
954
|
+
type: Object.keys(this.templates).find(key => this.templates[key] === template),
|
|
955
|
+
consequence: null,
|
|
956
|
+
context: context,
|
|
957
|
+
urgency: this.calculateUrgency(template, context),
|
|
958
|
+
theme: this.determineTheme(template, context),
|
|
959
|
+
difficulty: this.calculateDifficultyTier(context.power_level || 0),
|
|
960
|
+
tags: template.tags || []
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// Apply custom rules if rule engine is enabled
|
|
965
|
+
if (this.enableRuleEngine) {
|
|
966
|
+
event = this.applyCustomRules(event, context);
|
|
967
|
+
}
|
|
968
|
+
return event;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Generate an event purely from Markov chains (v2.0.0)
|
|
973
|
+
* @param {Object} context - Generation context
|
|
974
|
+
* @returns {Object} Generated event
|
|
975
|
+
*/
|
|
976
|
+
generatePureMarkovEvent(context) {
|
|
977
|
+
try {
|
|
978
|
+
const titleGenerated = this.markovGenerator.generate({
|
|
979
|
+
minLength: 15,
|
|
980
|
+
maxLength: 40,
|
|
981
|
+
maxTries: 10
|
|
982
|
+
});
|
|
983
|
+
let title = titleGenerated && titleGenerated.string ? titleGenerated.string.trim().charAt(0).toUpperCase() + titleGenerated.string.trim().slice(1) : 'Mysterious Occurrence';
|
|
984
|
+
if (title.length > 35) {
|
|
985
|
+
title = title.substring(0, 32) + '...';
|
|
986
|
+
}
|
|
987
|
+
const narrativeGenerated = this.markovGenerator.generate({
|
|
988
|
+
minLength: 50,
|
|
989
|
+
maxLength: 120,
|
|
990
|
+
maxTries: 15
|
|
991
|
+
});
|
|
992
|
+
const narrative = narrativeGenerated && narrativeGenerated.string ? narrativeGenerated.string : 'Something extraordinary has occurred that demands your attention.';
|
|
993
|
+
const descriptionGenerated = this.markovGenerator.generate({
|
|
994
|
+
minLength: 30,
|
|
995
|
+
maxLength: 80,
|
|
996
|
+
maxTries: 10
|
|
997
|
+
});
|
|
998
|
+
let description = narrative;
|
|
999
|
+
if (descriptionGenerated && descriptionGenerated.string && descriptionGenerated.string.length > 20) {
|
|
1000
|
+
description = descriptionGenerated.string + '. ' + narrative.charAt(0).toLowerCase() + narrative.slice(1);
|
|
1001
|
+
}
|
|
1002
|
+
const choices = this.generateMarkovChoices(context);
|
|
1003
|
+
return {
|
|
1004
|
+
id: `event_${Date.now()}_${this.chance.guid().substring(0, 8)}`,
|
|
1005
|
+
title: title,
|
|
1006
|
+
description: description,
|
|
1007
|
+
narrative: narrative,
|
|
1008
|
+
choices: choices,
|
|
1009
|
+
type: 'MARKOV_GENERATED',
|
|
1010
|
+
consequence: null,
|
|
1011
|
+
context: context,
|
|
1012
|
+
urgency: 'normal',
|
|
1013
|
+
theme: 'custom',
|
|
1014
|
+
difficulty: this.calculateDifficultyTier(context.power_level || 0),
|
|
1015
|
+
tags: []
|
|
1016
|
+
};
|
|
1017
|
+
} catch (error) {
|
|
1018
|
+
console.warn('Pure Markov generation failed, falling back to template:', error.message);
|
|
1019
|
+
return this.generateTemplateBasedEvent(context);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Generate choices for pure Markov events
|
|
1025
|
+
* @param {Object} context - Generation context
|
|
1026
|
+
* @returns {Array} Generated choices
|
|
1027
|
+
*/
|
|
1028
|
+
generateMarkovChoices(context) {
|
|
1029
|
+
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'];
|
|
1030
|
+
const numChoices = this.chance.integer({
|
|
1031
|
+
min: 2,
|
|
1032
|
+
max: 4
|
|
1033
|
+
});
|
|
1034
|
+
const selectedChoices = this.chance.pickset(choiceTemplates, numChoices);
|
|
1035
|
+
return selectedChoices.map((text, index) => {
|
|
1036
|
+
const effects = {};
|
|
1037
|
+
if (this.chance.bool({
|
|
1038
|
+
likelihood: 60
|
|
1039
|
+
})) {
|
|
1040
|
+
effects.gold = this.chance.integer({
|
|
1041
|
+
min: -50,
|
|
1042
|
+
max: 100
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
if (this.chance.bool({
|
|
1046
|
+
likelihood: 40
|
|
1047
|
+
})) {
|
|
1048
|
+
effects.reputation = this.chance.integer({
|
|
1049
|
+
min: -10,
|
|
1050
|
+
max: 20
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
if (this.chance.bool({
|
|
1054
|
+
likelihood: 30
|
|
1055
|
+
})) {
|
|
1056
|
+
effects.knowledge = this.chance.integer({
|
|
1057
|
+
min: 5,
|
|
1058
|
+
max: 25
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
return {
|
|
1062
|
+
text: text,
|
|
1063
|
+
effect: effects,
|
|
1064
|
+
consequence: `markov_choice_${index}`
|
|
1065
|
+
};
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Fallback method for pure Markov generation failures
|
|
1071
|
+
* @param {Object} context - Generation context
|
|
1072
|
+
* @returns {Object} Generated event
|
|
1073
|
+
*/
|
|
1074
|
+
generateTemplateBasedEvent(context) {
|
|
937
1075
|
const template = this.selectTemplate(context);
|
|
938
1076
|
const scaledChoices = this.scaleEffectsForDifficulty(this.generateContextualChoices(template.choices, context), context);
|
|
939
1077
|
return {
|
|
@@ -951,6 +1089,96 @@ class RPGEventGenerator {
|
|
|
951
1089
|
};
|
|
952
1090
|
}
|
|
953
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* Apply custom rules to an event (v2.0.0)
|
|
1094
|
+
* @param {Object} event - The generated event
|
|
1095
|
+
* @param {Object} context - The generation context
|
|
1096
|
+
* @returns {Object} Modified event with rules applied
|
|
1097
|
+
*/
|
|
1098
|
+
applyCustomRules(event, context) {
|
|
1099
|
+
let modifiedEvent = event;
|
|
1100
|
+
for (const [ruleName, rule] of Object.entries(this.customRules)) {
|
|
1101
|
+
if (this.ruleEngine.evaluateRule(context, rule)) {
|
|
1102
|
+
modifiedEvent = this.ruleEngine.applyRuleEffects(modifiedEvent, rule, context);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
return modifiedEvent;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* Add a custom rule to the rule engine (v2.0.0)
|
|
1110
|
+
* @param {string} name - Unique rule name
|
|
1111
|
+
* @param {Object} rule - Rule definition
|
|
1112
|
+
* @param {Array} rule.conditions - Array of condition objects
|
|
1113
|
+
* @param {Object} rule.effects - Effects to apply when conditions are met
|
|
1114
|
+
*/
|
|
1115
|
+
addCustomRule(name, rule) {
|
|
1116
|
+
this.customRules[name] = rule;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Remove a custom rule (v2.0.0)
|
|
1121
|
+
* @param {string} name - Rule name to remove
|
|
1122
|
+
*/
|
|
1123
|
+
removeCustomRule(name) {
|
|
1124
|
+
if (this.customRules[name]) {
|
|
1125
|
+
delete this.customRules[name];
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* Get all custom rules (v2.0.0)
|
|
1131
|
+
* @returns {Object} All custom rules
|
|
1132
|
+
*/
|
|
1133
|
+
getCustomRules() {
|
|
1134
|
+
return {
|
|
1135
|
+
...this.customRules
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Clear all custom rules (v2.0.0)
|
|
1141
|
+
*/
|
|
1142
|
+
clearCustomRules() {
|
|
1143
|
+
this.customRules = {};
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* Validate a custom rule definition (v2.0.0)
|
|
1148
|
+
* @param {Object} rule - Rule to validate
|
|
1149
|
+
* @returns {Object} Validation result { valid: boolean, errors: Array }
|
|
1150
|
+
*/
|
|
1151
|
+
validateCustomRule(rule) {
|
|
1152
|
+
const errors = [];
|
|
1153
|
+
if (!rule || typeof rule !== 'object') {
|
|
1154
|
+
errors.push('Rule must be an object');
|
|
1155
|
+
return {
|
|
1156
|
+
valid: false,
|
|
1157
|
+
errors
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
if (rule.conditions && !Array.isArray(rule.conditions)) {
|
|
1161
|
+
errors.push('Conditions must be an array');
|
|
1162
|
+
}
|
|
1163
|
+
if (rule.effects && typeof rule.effects !== 'object') {
|
|
1164
|
+
errors.push('Effects must be an object');
|
|
1165
|
+
}
|
|
1166
|
+
if (rule.conditions && Array.isArray(rule.conditions)) {
|
|
1167
|
+
rule.conditions.forEach((condition, index) => {
|
|
1168
|
+
if (!condition.type) {
|
|
1169
|
+
errors.push(`Condition ${index} missing type`);
|
|
1170
|
+
}
|
|
1171
|
+
if (!this.ruleEngine.conditionEvaluators[condition.type]) {
|
|
1172
|
+
errors.push(`Condition ${index} has unknown type: ${condition.type}`);
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
return {
|
|
1177
|
+
valid: errors.length === 0,
|
|
1178
|
+
errors
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
|
|
954
1182
|
/**
|
|
955
1183
|
* Generate multiple events at once
|
|
956
1184
|
* @param {Object} playerContext - Player stats and state
|
|
@@ -988,6 +1216,163 @@ class RPGEventGenerator {
|
|
|
988
1216
|
this.initializeRelationshipRules();
|
|
989
1217
|
}
|
|
990
1218
|
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Initialize the custom rule engine system (v2.0.0)
|
|
1222
|
+
*/
|
|
1223
|
+
initializeRuleEngine() {
|
|
1224
|
+
const ruleEngine = {
|
|
1225
|
+
rules: new Map(),
|
|
1226
|
+
evaluators: new Map(),
|
|
1227
|
+
conditions: new Map(),
|
|
1228
|
+
conditionEvaluators: {},
|
|
1229
|
+
evaluateCondition: function (context, condition) {
|
|
1230
|
+
const evaluator = this.conditionEvaluators[condition.type];
|
|
1231
|
+
if (!evaluator) {
|
|
1232
|
+
console.warn(`Unknown condition type: ${condition.type}`);
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
return evaluator(context, condition.params || {}, this);
|
|
1236
|
+
},
|
|
1237
|
+
initializeConditionEvaluators: function () {
|
|
1238
|
+
const self = this;
|
|
1239
|
+
this.conditionEvaluators = {
|
|
1240
|
+
stat_greater_than: (context, params) => {
|
|
1241
|
+
var _context$player;
|
|
1242
|
+
const stat = ((_context$player = context.player) === null || _context$player === void 0 ? void 0 : _context$player[params.stat]) || context[params.stat] || 0;
|
|
1243
|
+
return stat > params.value;
|
|
1244
|
+
},
|
|
1245
|
+
stat_less_than: (context, params) => {
|
|
1246
|
+
var _context$player2;
|
|
1247
|
+
const stat = ((_context$player2 = context.player) === null || _context$player2 === void 0 ? void 0 : _context$player2[params.stat]) || context[params.stat] || 0;
|
|
1248
|
+
return stat < params.value;
|
|
1249
|
+
},
|
|
1250
|
+
stat_between: (context, params) => {
|
|
1251
|
+
var _context$player3;
|
|
1252
|
+
const stat = ((_context$player3 = context.player) === null || _context$player3 === void 0 ? void 0 : _context$player3[params.stat]) || context[params.stat] || 0;
|
|
1253
|
+
return stat >= params.min && stat <= params.max;
|
|
1254
|
+
},
|
|
1255
|
+
has_item: (context, params) => {
|
|
1256
|
+
var _context$player4;
|
|
1257
|
+
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;
|
|
1258
|
+
},
|
|
1259
|
+
location_is: (context, params) => {
|
|
1260
|
+
return context.location === params.location;
|
|
1261
|
+
},
|
|
1262
|
+
season_is: (context, params) => {
|
|
1263
|
+
return context.season === params.season;
|
|
1264
|
+
},
|
|
1265
|
+
career_is: (context, params) => {
|
|
1266
|
+
var _context$player5;
|
|
1267
|
+
return (((_context$player5 = context.player) === null || _context$player5 === void 0 ? void 0 : _context$player5.career) || context.career) === params.career;
|
|
1268
|
+
},
|
|
1269
|
+
time_greater_than: (context, params) => {
|
|
1270
|
+
var _context$time;
|
|
1271
|
+
return (((_context$time = context.time) === null || _context$time === void 0 ? void 0 : _context$time.day) || 0) > params.days;
|
|
1272
|
+
},
|
|
1273
|
+
relationship_status: (context, params) => {
|
|
1274
|
+
var _context$relationship;
|
|
1275
|
+
const relationship = (_context$relationship = context.relationships) === null || _context$relationship === void 0 ? void 0 : _context$relationship.find(r => r.name === params.npc);
|
|
1276
|
+
if (!relationship) return false;
|
|
1277
|
+
return relationship.relationship >= params.min && relationship.relationship <= params.max;
|
|
1278
|
+
},
|
|
1279
|
+
random_chance: (context, params) => {
|
|
1280
|
+
return Math.random() < params.probability;
|
|
1281
|
+
},
|
|
1282
|
+
and: (context, params, ruleEngine) => {
|
|
1283
|
+
return params.conditions.every(condition => ruleEngine.evaluateCondition(context, condition));
|
|
1284
|
+
},
|
|
1285
|
+
or: (context, params, ruleEngine) => {
|
|
1286
|
+
return params.conditions.some(condition => ruleEngine.evaluateCondition(context, condition));
|
|
1287
|
+
},
|
|
1288
|
+
not: (context, params, ruleEngine) => {
|
|
1289
|
+
return !ruleEngine.evaluateCondition(context, params.condition);
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
},
|
|
1293
|
+
evaluateRule: function (context, rule) {
|
|
1294
|
+
if (!rule.conditions || rule.conditions.length === 0) {
|
|
1295
|
+
return true;
|
|
1296
|
+
}
|
|
1297
|
+
return rule.conditions.every(condition => this.evaluateCondition(context, condition));
|
|
1298
|
+
},
|
|
1299
|
+
applyRuleEffects: function (event, rule, context) {
|
|
1300
|
+
if (!rule.effects) return event;
|
|
1301
|
+
const modifiedEvent = JSON.parse(JSON.stringify(event));
|
|
1302
|
+
if (rule.effects.modifyChoices) {
|
|
1303
|
+
modifiedEvent.choices = modifiedEvent.choices.map(choice => ({
|
|
1304
|
+
...choice,
|
|
1305
|
+
effect: this.applyEffectModifiers(choice.effect, rule.effects.modifyChoices, context)
|
|
1306
|
+
}));
|
|
1307
|
+
}
|
|
1308
|
+
if (rule.effects.addChoices) {
|
|
1309
|
+
modifiedEvent.choices = [...modifiedEvent.choices, ...rule.effects.addChoices];
|
|
1310
|
+
}
|
|
1311
|
+
if (rule.effects.modifyTitle) {
|
|
1312
|
+
modifiedEvent.title = this.applyTextModifiers(modifiedEvent.title, rule.effects.modifyTitle, context);
|
|
1313
|
+
}
|
|
1314
|
+
if (rule.effects.modifyNarrative) {
|
|
1315
|
+
modifiedEvent.narrative = this.applyTextModifiers(modifiedEvent.narrative, rule.effects.modifyNarrative, context);
|
|
1316
|
+
}
|
|
1317
|
+
if (rule.effects.setDifficulty) {
|
|
1318
|
+
modifiedEvent.difficulty = rule.effects.setDifficulty;
|
|
1319
|
+
}
|
|
1320
|
+
if (rule.effects.addTags) {
|
|
1321
|
+
if (!modifiedEvent.tags) modifiedEvent.tags = [];
|
|
1322
|
+
modifiedEvent.tags = [...modifiedEvent.tags, ...rule.effects.addTags];
|
|
1323
|
+
}
|
|
1324
|
+
return modifiedEvent;
|
|
1325
|
+
},
|
|
1326
|
+
applyEffectModifiers: function (effect, modifiers, context) {
|
|
1327
|
+
const modified = {
|
|
1328
|
+
...effect
|
|
1329
|
+
};
|
|
1330
|
+
if (modifiers.multiply) {
|
|
1331
|
+
Object.keys(modifiers.multiply).forEach(key => {
|
|
1332
|
+
if (modified[key] !== undefined) {
|
|
1333
|
+
if (Array.isArray(modified[key])) {
|
|
1334
|
+
modified[key] = modified[key].map(val => Math.round(val * modifiers.multiply[key]));
|
|
1335
|
+
} else {
|
|
1336
|
+
modified[key] = Math.round(modified[key] * modifiers.multiply[key]);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
if (modifiers.add) {
|
|
1342
|
+
Object.keys(modifiers.add).forEach(key => {
|
|
1343
|
+
if (modified[key] !== undefined) {
|
|
1344
|
+
if (Array.isArray(modified[key])) {
|
|
1345
|
+
modified[key] = modified[key].map(val => val + modifiers.add[key]);
|
|
1346
|
+
} else {
|
|
1347
|
+
modified[key] = modified[key] + modifiers.add[key];
|
|
1348
|
+
}
|
|
1349
|
+
} else {
|
|
1350
|
+
modified[key] = modifiers.add[key];
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
return modified;
|
|
1355
|
+
},
|
|
1356
|
+
applyTextModifiers: function (text, modifiers, context) {
|
|
1357
|
+
let modifiedText = text;
|
|
1358
|
+
if (modifiers.replace) {
|
|
1359
|
+
Object.keys(modifiers.replace).forEach(pattern => {
|
|
1360
|
+
const replacement = modifiers.replace[pattern];
|
|
1361
|
+
modifiedText = modifiedText.replace(new RegExp(pattern, 'g'), replacement);
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
if (modifiers.append) {
|
|
1365
|
+
modifiedText += modifiers.append;
|
|
1366
|
+
}
|
|
1367
|
+
if (modifiers.prepend) {
|
|
1368
|
+
modifiedText = modifiers.prepend + modifiedText;
|
|
1369
|
+
}
|
|
1370
|
+
return modifiedText;
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
ruleEngine.initializeConditionEvaluators();
|
|
1374
|
+
return ruleEngine;
|
|
1375
|
+
}
|
|
991
1376
|
initializeTemplateSystem(options) {
|
|
992
1377
|
if (this.enableTemplates && this.templateLibrary) {
|
|
993
1378
|
try {
|
|
@@ -1022,7 +1407,6 @@ class RPGEventGenerator {
|
|
|
1022
1407
|
}
|
|
1023
1408
|
}
|
|
1024
1409
|
});
|
|
1025
|
-
console.log(`Loaded ${loadedCount} templates from ${genre} library`);
|
|
1026
1410
|
} catch (error) {
|
|
1027
1411
|
console.warn('Template loading failed:', error.message);
|
|
1028
1412
|
}
|
|
@@ -1468,7 +1852,7 @@ class RPGEventGenerator {
|
|
|
1468
1852
|
template: this.templates[stage.template]
|
|
1469
1853
|
};
|
|
1470
1854
|
triggeredEvents.push(event);
|
|
1471
|
-
break;
|
|
1855
|
+
break;
|
|
1472
1856
|
}
|
|
1473
1857
|
}
|
|
1474
1858
|
}
|
|
@@ -1519,7 +1903,6 @@ class RPGEventGenerator {
|
|
|
1519
1903
|
day: this.timeSystem.currentDay,
|
|
1520
1904
|
season: this.timeSystem.currentSeason,
|
|
1521
1905
|
year: Math.ceil(this.timeSystem.currentDay / 360),
|
|
1522
|
-
// Roughly 360 days per year
|
|
1523
1906
|
seasonalModifiers: ((_this$seasonalEvents$ = this.seasonalEvents[this.timeSystem.currentSeason]) === null || _this$seasonalEvents$ === void 0 ? void 0 : _this$seasonalEvents$.modifiers) || {}
|
|
1524
1907
|
};
|
|
1525
1908
|
}
|
|
@@ -2104,8 +2487,7 @@ class RPGEventGenerator {
|
|
|
2104
2487
|
};
|
|
2105
2488
|
Object.keys(adjustedWeights).forEach(templateKey => {
|
|
2106
2489
|
const rating = challengeRatings[templateKey] || 5;
|
|
2107
|
-
const powerRatio = powerLevel / 100;
|
|
2108
|
-
|
|
2490
|
+
const powerRatio = powerLevel / 100;
|
|
2109
2491
|
if (rating < powerRatio + 2) {
|
|
2110
2492
|
adjustedWeights[templateKey] *= 0.5;
|
|
2111
2493
|
} else if (rating >= powerRatio + 2 && rating <= powerRatio + 5) {
|
|
@@ -2448,7 +2830,7 @@ class RPGEventGenerator {
|
|
|
2448
2830
|
break;
|
|
2449
2831
|
case 'stress':
|
|
2450
2832
|
case 'happiness':
|
|
2451
|
-
if (context.age > 40) multiplier *= 1.1;
|
|
2833
|
+
if (context.age > 40) multiplier *= 1.1;
|
|
2452
2834
|
break;
|
|
2453
2835
|
}
|
|
2454
2836
|
return multiplier;
|
|
@@ -3171,7 +3553,7 @@ class RPGEventGenerator {
|
|
|
3171
3553
|
*/
|
|
3172
3554
|
getSystemStatus() {
|
|
3173
3555
|
return {
|
|
3174
|
-
version: '
|
|
3556
|
+
version: '2.0.0',
|
|
3175
3557
|
language: this.language,
|
|
3176
3558
|
availableLanguages: Array.from(this.locales.keys()),
|
|
3177
3559
|
modifiersEnabled: this.enableModifiers,
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-event-generator",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "RPG Event Generator v2.0.0 - Complete procedural event generation with 429+ templates, rule engine, and theme creator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/",
|
|
8
8
|
"templates/",
|
|
9
|
+
"scripts/",
|
|
9
10
|
"demo.js",
|
|
10
11
|
"README.md",
|
|
11
12
|
"LICENSE"
|
|
@@ -13,7 +14,14 @@
|
|
|
13
14
|
"scripts": {
|
|
14
15
|
"test": "jest",
|
|
15
16
|
"build": "babel src --out-dir dist",
|
|
16
|
-
"
|
|
17
|
+
"build:browser": "npm run build && browserify dist/index.js --standalone RPGEventGenerator -o demo-web/rpg-event-generator.js",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"demo": "node demo.js",
|
|
20
|
+
"economy:list": "node scripts/event-economy.js list-themes",
|
|
21
|
+
"economy:stats": "node scripts/event-economy.js stats",
|
|
22
|
+
"export:unity": "node scripts/export-templates.js unity",
|
|
23
|
+
"export:godot": "node scripts/export-templates.js godot",
|
|
24
|
+
"export:typescript": "node scripts/export-templates.js typescript"
|
|
17
25
|
},
|
|
18
26
|
"keywords": [
|
|
19
27
|
"rpg",
|
|
@@ -55,6 +63,7 @@
|
|
|
55
63
|
"@babel/cli": "^7.23.0",
|
|
56
64
|
"@babel/core": "^7.23.0",
|
|
57
65
|
"@babel/preset-env": "^7.23.0",
|
|
66
|
+
"browserify": "^17.0.0",
|
|
58
67
|
"jest": "^29.7.0",
|
|
59
68
|
"jest-environment-node": "^29.7.0"
|
|
60
69
|
},
|
|
@@ -64,6 +73,10 @@
|
|
|
64
73
|
"^.+\\.(js|jsx)$": "babel-jest"
|
|
65
74
|
}
|
|
66
75
|
},
|
|
76
|
+
"bin": {
|
|
77
|
+
"rpg-events": "./scripts/event-economy.js",
|
|
78
|
+
"rpg-export": "./scripts/export-templates.js"
|
|
79
|
+
},
|
|
67
80
|
"engines": {
|
|
68
81
|
"node": ">=14.0.0"
|
|
69
82
|
}
|