Skip to content

Instantly share code, notes, and snippets.

@goblinHordes
Created October 30, 2013 06:31
Show Gist options
  • Save goblinHordes/7228010 to your computer and use it in GitHub Desktop.
Save goblinHordes/7228010 to your computer and use it in GitHub Desktop.
Basic Fantasy Role-Playing Game, Random PC Generator for Roll20 API
on("chat:message", function(msg) {
if(msg.type == "api" && msg.content.indexOf("!random_pc") !== -1) {
try {
options = JSON.parse(msg.content.substring(10));
} catch( err ) { options = {} }
pc = BFRpg.PlayerCharacter.random(options);
/*
newChar = createObj('character', {name:pc.fullname()});
newChar.set('gmnotes', 'New Character');
createObj('attribute', { characterid: newChar.id, name: 'Race', current: pc.race.strings.name.toProperCase()});
createObj('attribute', { characterid: newChar.id, name: 'Class', current: pc.class.strings.name.toProperCase()});
createObj('attribute', { characterid: newChar.id, name: 'Sex', current: pc.sex.toProperCase()});
createObj('attribute', { characterid: newChar.id, name: 'Str', current: pc.statBlock.strength});
createObj('attribute', { characterid: newChar.id, name: 'Int', current: pc.statBlock.intelligence});
createObj('attribute', { characterid: newChar.id, name: 'Wis', current: pc.statBlock.wisdom});
createObj('attribute', { characterid: newChar.id, name: 'Dex', current: pc.statBlock.dexterity});
createObj('attribute', { characterid: newChar.id, name: 'Con', current: pc.statBlock.constitution});
createObj('attribute', { characterid: newChar.id, name: 'Cha', current: pc.statBlock.charisma});
//*/
sendChat(msg.who, '/me is rolling a new Player Character');
sendChat(msg.who, '/direct <b>' + pc.fullname() + '</b> ' + pc.maxHitPoints + 'HP<br><i>' + pc.sex + ' ' +
pc.race.strings.name + ' ' + pc.class.strings.name + '</i><br>' + pc.statBlock);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment