Skip to content

Instantly share code, notes, and snippets.

@Teino1978-Corp
Created November 23, 2015 02:23
Show Gist options
  • Save Teino1978-Corp/e6b9cd255df59afe4b53 to your computer and use it in GitHub Desktop.
Save Teino1978-Corp/e6b9cd255df59afe4b53 to your computer and use it in GitHub Desktop.
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#!/usr/bin/env python
// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var postComplete = function(succeeded) {
topDiv.find('.emote-message-posting').hide();
var m = topDiv.find(
succeeded ? '.emote-message-posted' : '.emote-message-failed');
m.show();
setTimeout(function() { m.fadeOut('slow'); }, 3000);
};
var rcPost = 'urn:x-belay://resouce-class/social-feed/post';
var showPanel = function(feedCap) {
topDiv.find('.emote-panel').show();
topDiv.find('.emote-post').click(function(ev) {
topDiv.find('.emote-message-posting').show();
feedCap.post(
{ body: ev.target.innerText, via: 'emote' },
function() { postComplete(true); },
function() { postComplete(false); }
);
ev.preventDefault();
return false;
});
};
onBelayReady(function() {
ui.resize(160, 90, false);
var feedCap = belay.outpost.info.post;
console.log(feedCap);
if (feedCap) {
showPanel(capServer.restore(feedCap));
}
else {
var invite = topDiv.find('.emote-invite');
invite.show();
ui.capDroppable(invite, rcPost, function(genCap, rc) {
genCap.post(rcPost, function(feedCap) {
invite.hide();
showPanel(feedCap);
belay.outpost.info.savePost.put(feedCap.serialize());
});
});
}
});
from collections import Counter
from random import choice
Advantage = Counter(advantage=1, threat=-1)
Blank = Counter()
Dark = Counter(dark=1)
Dispair = Counter(dispair=1, success=-1)
Failure = Counter(failure=1, success=-1)
Light = Counter(light=1)
Success = Counter(success=1)
Threat = Counter(threat=1, advantage=-1)
Triumph = Counter(triumph=1)
Difficulty = (
Blank, Failure, Failure + Failure, Threat, Threat,
Threat, Threat + Threat, Threat + Failure,
)
Ability = (
Blank, Success, Success, Success + Success, Advantage,
Advantage, Advantage + Success, Advantage + Advantage
)
Boost = (
Blank, Blank, Advantage + Advantage, Advantage, Success + Advantage, Success
)
Setback = (
Blank, Blank, Failure, Failure, Threat, Threat
)
Proficiency = (
Blank, Success, Success, Success + Success, Success + Success, Advantage,
Success + Advantage, Success + Advantage, Success + Advantage,
Advantage + Advantage, Advantage + Advantage, Triumph
)
Challenge = (
Blank, Failure, Failure, Failure + Failure, Failure + Failure, Threat,
Threat, Failure + Threat, Failure + Threat, Threat + Threat,
Threat + Threat, Dispair
)
Force = (
Dark, Dark, Dark, Dark, Dark, Dark, Dark + Dark,
Light, Light, Light + Light, Light + Light, Light + Light
)
def roll(
boost=0,
setback=0,
ability=0,
difficulty=0,
proficiency=0,
challenge=0,
force=0
):
boost = sum((choice(Boost) for _ in range(boost)), Blank)
setback = sum((choice(Setback) for _ in range(setback)), Blank)
ability = sum((choice(Ability) for _ in range(ability)), Blank)
difficulty = sum((choice(Difficulty) for _ in range(difficulty)), Blank)
proficiency = sum((choice(Proficiency) for _ in range(proficiency)), Blank)
challenge = sum((choice(Challenge) for _ in range(challenge)), Blank)
force = sum((choice(Force) for _ in range(force)), Blank)
return (
boost + setback + ability + difficulty
+ proficiency + challenge + force
)
if __name__ == '__main__':
print roll(proficiency=4, challenge=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment