<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/alex-2012.css" ?>
<rss version="2.0"
    xmlns:wiki="http://purl.org/rss/1.0/modules/wiki/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:cc="http://web.resource.org/cc/"
    xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<title>Alex Schroeder: Diary</title>
<link>http://alexschroeder.ch/wiki/Diary</link>
<atom:link href="http://www.google.com/profiles/kensanata" rel="me" type="text/html" />
<atom:link href="http://alexschroeder.ch/wiki?action=rss;full=1" rel="self" type="application/rss+xml" />
<description>The Homepage of Alex Schroeder.</description>
<pubDate>Tue, 18 Jun 2013 18:38:58 GMT</pubDate>
<lastBuildDate>Tue, 18 Jun 2013 18:38:58 GMT</lastBuildDate>
<generator>Oddmuse</generator>
<copyright>Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation.</copyright>
<cc:license>http://www.gnu.org/copyleft/fdl.html</cc:license>
<image>
<url>http://alexschroeder.ch/pics/alex.png</url>
<title>Alex Schroeder: Diary</title>
<link>http://alexschroeder.ch/wiki</link>
</image>

<item>
<title>Distributing XP With Emacs</title>
<link>http://alexschroeder.ch/wiki/2013-05-08_Distributing_XP_With_Emacs</link>
<guid>http://alexschroeder.ch/wiki/2013-05-08_Distributing_XP_With_Emacs</guid>
<description>&lt;p&gt;This topic ties together two topics that probably don&amp;#x2019;t see too much overlap.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;I play role-playing games of the D&amp;amp;D old school variety.&lt;/li&gt;&lt;li&gt;I use Emacs to help me do simple stuff on a daily basis.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The problem: the party of characters my players run is &lt;em style="font-style: normal; letter-spacing: 0.125em; padding-left: 0.125em;"&gt;huge&lt;/em&gt;. Even if there are usually only around ten characters that are part of a single session, there are more than thirty primary and secondary characters &lt;a class="url http outside" href="http://campaignwiki.org/wiki/F%C3%BCnfWinde/Status"&gt;on the status page&lt;/a&gt;. Given &lt;a class="url http outside" href="http://campaignwiki.org/wiki/F%C3%BCnfWinde/raw/Status"&gt;the wiki table&lt;/a&gt; for the status page, how can I quickly add up the correct XP and gold values? Any XP gained is shared equally amongst the characters that took part in the session but any gold gained is distributed according to each characters share. Primary characters get a full share, secondary characters get a third of a share.&lt;/p&gt;&lt;p&gt;I used Emacs widget mode to create a page like this:&lt;/p&gt;&lt;pre class="real"&gt;XP total:   805          
Gold total: 7191         
[X] Schalk
[ ] Uluf
[ ] Witschik
[X] Schachtmann
[ ] Sirius
[X] Logard
[X] Arnd
[X] Tinaya
[ ] Pyrula
[ ] Pijo
[ ] Garo
[X] Zeta
[ ] Pipo
[X] Fusstritt
[ ] Thor
[ ] Jack
[ ] Gloria
[ ] Hermann
[ ] Urs
[ ] Alpha
[ ] Beta
[ ] Gamma
[ ] Boden
[ ] Basel
[ ] Bern
[X] Nuschka
[ ] Moranor
[ ] Axirios Hectaxius

[Go!]&lt;/pre&gt;&lt;p&gt;And here&amp;#x2019;s the code to do it:&lt;/p&gt;&lt;pre class="real"&gt;(defconst fünf-winde-regexp "^\\(|\\[\\[\\(.*?\\)\\]\\][ \t]*|[ \t]*\\(1\\|1/3\\)[ \t]*\\)|\\([ \t]*[0-9]+[ \t]*\\)|\\([ \t]*[0-9]+[ \t]*\\)"
  "Regular expression to parse the Status page.
\(let ((str (match-string 1))
      (name (match-string 2))
      (share (match-string 3))
      (xp (match-string 4))
      (gold (match-string 5)))
    ...\)")

(defvar fünf-winde-buf nil
  "Source buffer.")

(defvar fünf-winde-xp nil
  "XP share.")

(defvar fünf-winde-gold nil
  "Gold share.")

(defvar fünf-winde-party nil
  "Charakters in the party.")

(defun fünf-winde-xp-and-gold ()
  "Hand out Gold and XP."
  (interactive)
  (let ((buf (current-buffer))
	(names))
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward fünf-winde-regexp nil t)
	(setq names (cons (match-string 2) names))))
    (switch-to-buffer "*Fünf Winde*")
    (kill-all-local-variables)
    (set (make-local-variable 'fünf-winde-buf) buf)
    (make-local-variable 'fünf-winde-xp)
    (make-local-variable 'fünf-winde-gold)
    (make-local-variable 'fünf-winde-party)
    (let ((inhibit-read-only t))
      (erase-buffer))
    (remove-overlays)
    (setq fünf-winde-xp
	  (widget-create 'integer
			 :size 13
			 :format "XP total:   %v\n"
			 0))
    (setq fünf-winde-gold
	  (widget-create 'integer
			 :size 13
			 :format "Gold total: %v\n"
			 0))
    (setq fünf-winde-party
	  (apply 'widget-create 'checklist
		 (mapcar (lambda (name)
			   `(item ,name))
			 (nreverse names))))
    (widget-insert "\n")
    (widget-create 'push-button
		   :notify (lambda (&amp;amp;rest ignore)
			     (fünf-winde-process
			      fünf-winde-buf
			      (widget-value fünf-winde-xp)
			      (widget-value fünf-winde-gold)
			      (widget-value fünf-winde-party)))
		   "Go!")
    (widget-insert "\n")
    (use-local-map widget-keymap)
    (local-set-key (kbd "q") 'bury-buffer)
    (local-set-key (kbd "SPC") 'widget-button-press)
    (local-set-key (kbd "&amp;lt;left&amp;gt;") 'widget-backward)
    (local-set-key (kbd "&amp;lt;up&amp;gt;") 'widget-backward)
    (local-set-key (kbd "&amp;lt;right&amp;gt;") 'widget-forward)
    (local-set-key (kbd "&amp;lt;down&amp;gt;") 'widget-forward)
    (widget-setup)
    (goto-char (point-min))
    (widget-forward 1)))

(defun fünf-winde-process (buf total-xp total-gold party)
  (message "(fünf-winde-process (get-buffer \"%s\") %d %d '%S)"
	   buf total-xp total-gold party)
  (switch-to-buffer buf)
  (save-excursion
    (let ((xp-shares 0)
	  (xp-share nil)
	  (gold-shares 0)
	  (gold-share nil))
      (goto-char (point-min))
      (while (re-search-forward fünf-winde-regexp nil t)
	(let ((name (match-string 2))
	      (share (match-string 3)))
	  (when (member name party)
	    (setq gold-shares (+ gold-shares
				 (cond ((string= share "1/2") 0.5)
				       ((string= share "1/3") (/ 1.0 3))
				       (t (string-to-number share))))
		  xp-shares (1+ xp-shares)))))
      (setq gold-share (/ total-gold gold-shares)
	    xp-share (/ total-xp xp-shares))
      (goto-char (point-min))
      (while (re-search-forward fünf-winde-regexp nil t)
	(let ((str (match-string 1))
	      (name (match-string 2))
	      (share (match-string 3))
	      (xp (match-string 4))
	      (gold (match-string 5)))
	  (when (member name party)
	    (setq gold (format (concat "%9d")
			       (+  (string-to-number gold)
				   (* gold-share (cond ((string= share "1/2") 0.5)
						       ((string= share "1/3") (/ 1.0 3))
						       (t (string-to-number share))))))
		  xp (format (concat "%9d")
			     (+  (string-to-number xp)
				 xp-share)))
	    (replace-match (concat str
				   "|" xp
				   "|" gold))))))))&lt;/pre&gt;&lt;p&gt;I&amp;#x2019;m not sure I&amp;#x2019;m spending my time wisely, but there you go. I used to have a simpler piece of code that helped me distribute XP and gold separately. The drawback was that it would ask me for every person in the table &amp;#x201c;was this character in the party? (y/n)&amp;#x201d; and that&amp;#x2019;s a lot of yes and no replies if you go through the list &lt;em&gt;twice&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;It&amp;#x2019;s also a stark reminder that simpler old rules doesn&amp;#x2019;t automatically mean less work for the referee. With D&amp;amp;D 3.5, I had a spreadsheet to compute the XP gained based on challenge rating and character level. It wasn&amp;#x2019;t something to do quickly without a book in front of me. Now the complexity of the task has been reduced, but the number of characters has exploded to compensate!&lt;/p&gt;&lt;p&gt;Tags: &lt;a class="outside tag" title="Tag" rel="tag" href="http://alexschroeder.ch/wiki?action=tag;id=Emacs"&gt;Emacs&lt;/a&gt; &lt;a class="feed tag" title="Feed for this tag" rel="feed" href="http://alexschroeder.ch/wiki/feed/full/Emacs"&gt;&lt;img src="http://alexschroeder.ch/pics/rss.png" alt="RSS" /&gt;&lt;/a&gt; &lt;a class="outside tag" title="Tag" rel="tag" href="http://alexschroeder.ch/wiki?action=tag;id=RPG"&gt;RPG&lt;/a&gt; &lt;a class="feed tag" title="Feed for this tag" rel="feed" href="http://alexschroeder.ch/wiki/feed/full/RPG"&gt;&lt;img src="http://alexschroeder.ch/pics/rss.png" alt="RSS" /&gt;&lt;/a&gt; &lt;a class="outside tag" title="Tag" rel="tag" href="http://alexschroeder.ch/wiki?action=tag;id=Old%20School"&gt;Old School&lt;/a&gt; &lt;a class="feed tag" title="Feed for this tag" rel="feed" href="http://alexschroeder.ch/wiki/feed/full/Old%20School"&gt;&lt;img src="http://alexschroeder.ch/pics/rss.png" alt="RSS" /&gt;&lt;/a&gt;&lt;/p&gt;</description>
<pubDate>Wed, 08 May 2013 13:17:38 GMT</pubDate>
<comments>http://alexschroeder.ch/wiki/Comments_on_2013-05-08_Distributing_XP_With_Emacs</comments>
<dc:contributor>AlexSchroeder</dc:contributor>
<wiki:status>new</wiki:status>
<wiki:importance>major</wiki:importance>
<wiki:version>1</wiki:version>
<wiki:history>http://alexschroeder.ch/wiki?action=history;id=2013-05-08_Distributing_XP_With_Emacs</wiki:history>
<wiki:diff>http://alexschroeder.ch/wiki?action=browse;diff=1;id=2013-05-08_Distributing_XP_With_Emacs</wiki:diff>
<category>Emacs</category>
<category>RPG</category>
<category>Old School</category>
</item>

<item>
<title>Emacs Wiki Redesign</title>
<link>http://alexschroeder.ch/wiki/2013-04-26_Emacs_Wiki_Redesign</link>
<guid>http://alexschroeder.ch/wiki/2013-04-26_Emacs_Wiki_Redesign</guid>
<description>&lt;p&gt;I finally &lt;a class="inter EmacsWiki outside" href="http://emacswiki.org/emacs?2013-04-24"&gt;installed the new theme for Emacs Wiki&lt;/a&gt;. Feel free to &lt;a class="inter EmacsWiki outside" href="http://emacswiki.org/emacs?Comments_on_2013-04-24"&gt;leave comments on the Talk page&lt;/a&gt;. Bootstrap allows me to make all the changes at run-time, ie. add a few scripts including a script that changes the wiki&amp;#x2019;s HTML (&lt;a class="url http outside" href="http://emacswiki.org/emacs/emacs-bootstrap.js"&gt;emacs-bootstrap.js&lt;/a&gt;) and a new CSS file (&lt;a class="url http outside" href="http://emacswiki.org/css/bootstrap.css"&gt;bootstrap.css&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;Since no changes to the script are necessary I can continue to provide the old theme for those that don&amp;#x2019;t feel like switching.&lt;/p&gt;&lt;p&gt;Tags: &lt;a class="outside tag" title="Tag" rel="tag" href="http://alexschroeder.ch/wiki?action=tag;id=Emacs"&gt;Emacs&lt;/a&gt; &lt;a class="feed tag" title="Feed for this tag" rel="feed" href="http://alexschroeder.ch/wiki/feed/full/Emacs"&gt;&lt;img src="http://alexschroeder.ch/pics/rss.png" alt="RSS" /&gt;&lt;/a&gt;&lt;/p&gt;</description>
<pubDate>Fri, 26 Apr 2013 12:42:35 GMT</pubDate>
<comments>http://alexschroeder.ch/wiki/Comments_on_2013-04-26_Emacs_Wiki_Redesign</comments>
<dc:contributor>AlexSchroeder</dc:contributor>
<wiki:status>new</wiki:status>
<wiki:importance>major</wiki:importance>
<wiki:version>1</wiki:version>
<wiki:history>http://alexschroeder.ch/wiki?action=history;id=2013-04-26_Emacs_Wiki_Redesign</wiki:history>
<wiki:diff>http://alexschroeder.ch/wiki?action=browse;diff=1;id=2013-04-26_Emacs_Wiki_Redesign</wiki:diff>
<category>Emacs</category>
</item>
</channel>
</rss>
