Ejemplo n.º 1
0
def _pdfblankgen(count, game):
	tmptexdir = "/tmp/moerder_" + game.id
	if not os.path.isdir(tmptexdir):
		os.mkdir(tmptexdir)
	shutil.copyfile(os.path.join(G.templatedir, "moerder.tex"), os.path.join(tmptexdir, "moerder.tex"))
	listfile = codecs.open(os.path.join(tmptexdir, "list.tex"), "w", "utf-8")
	for p in range(0, count):
		for roundid in sorted(game.rounds):
			round = game.rounds[roundid]
			roundname = round.name if len(game.rounds) > 1 else ''
			#listfile.write("\Auftrag{Gamename}{Gameid}{Victim}{Killer}{Signaturecode}{Spielende}{URL}\n")
			listfile.write(u"\\Auftrag{%s}{%s}{%s\\\\%s}{%s\\\\%s}{%s}{%s}{%s}{%s}\n" % 
				(
					utils.latexEsc(game.name), 
					utils.latexEsc(game.id), 
					'\underline{\hskip4.5cm}', 
					'\underline{\hskip4.5cm}', 
					'\underline{\hskip2.5cm}', 
					'\underline{\hskip2.5cm}', 
					'\underline{\hskip2cm}', 
					utils.latexEsc(game.enddate.strftime("%d.%m.%Y %H:%M")), 
					utils.latexEsc(_url(req, 'view',  game.id)), 
					utils.latexEsc(roundname)
				) 
			)
	listfile.close()
	cwd = os.getcwd()
	os.chdir(tmptexdir)
	os.system("xelatex moerder.tex")
	os.chdir(cwd)
	shutil.copyfile(tmptexdir + "/moerder.pdf", os.path.join(G.savegamedir, "%s.pdf" % game.id))
Ejemplo n.º 2
0
def _pdfblankgen(count, game):
    tmptexdir = "/tmp/moerder_" + game.id
    if not os.path.isdir(tmptexdir):
        os.mkdir(tmptexdir)
    shutil.copyfile(os.path.join(G.templatedir, "moerder.tex"),
                    os.path.join(tmptexdir, "moerder.tex"))
    listfile = codecs.open(os.path.join(tmptexdir, "list.tex"), "w", "utf-8")
    for p in range(0, count):
        for roundid in sorted(game.rounds):
            round = game.rounds[roundid]
            roundname = round.name if len(game.rounds) > 1 else ''
            #listfile.write("\Auftrag{Gamename}{Gameid}{Victim}{Killer}{Signaturecode}{Spielende}{URL}\n")
            listfile.write(
                u"\\Auftrag{%s}{%s}{%s\\\\%s}{%s\\\\%s}{%s}{%s}{%s}{%s}\n" %
                (utils.latexEsc(game.name), utils.latexEsc(
                    game.id), '\underline{\hskip4.5cm}',
                 '\underline{\hskip4.5cm}', '\underline{\hskip2.5cm}',
                 '\underline{\hskip2.5cm}', '\underline{\hskip2cm}',
                 utils.latexEsc(game.enddate.strftime("%d.%m.%Y %H:%M")),
                 utils.latexEsc(_url(req, 'view',
                                     game.id)), utils.latexEsc(roundname)))
    listfile.close()
    cwd = os.getcwd()
    os.chdir(tmptexdir)
    os.system("xelatex moerder.tex")
    os.chdir(cwd)
    shutil.copyfile(tmptexdir + "/moerder.pdf",
                    os.path.join(G.savegamedir, "%s.pdf" % game.id))
Ejemplo n.º 3
0
 def pdfgen(self, players=None, participants=None):
     fname = self.id
     if (players is None):
         players = self.players
     if (len(players) == 0):
         return
     elif (len(players) == 1):
         fname = self.id + '_' + players[0].public_id
     if participants is not None:
         fname = self.id + '_gamemaster'
     tmptexdir = "/tmp/moerder_" + fname
     if not os.path.isdir(tmptexdir):
         os.mkdir(tmptexdir)
     tmplfile = "moerder.tex"
     if (len(self.rounds) % 2 == 0 and len(players) > 1):
         tmplfile = "moerder2.tex"
     shutil.copyfile(os.path.join(self.templatedir, tmplfile),
                     os.path.join(tmptexdir, "moerder.tex"))
     listfile = codecs.open(os.path.join(tmptexdir, "list.tex"), "w",
                            "utf-8")
     #for roundid,round in self.rounds.iteritems():
     #	for participant in round.participants:
     #		killer = participant.player
     #		victim = round.getInitialVictim(participant).player
     for killer in sorted(players, key=lambda x: x.name):
         assignments = 0
         for roundid, round in self.rounds.iteritems():
             participant = round.getParticipant(killer)
             if participant is not None and participant.alive() and (
                     participants is None or participant in participants):
                 victim = round.getCurrentVictim(killer)
                 if victim is not None:
                     roundname = round.name if len(self.rounds) > 1 else ''
                     #listfile.write("\Auftrag{Gamename}{Gameid}{Victim}{Killer}{Signaturecode}{Spielende}{URL}\n")
                     listfile.write(
                         u"\\Auftrag{%s}{%s}{%s\\\\%s}{%s\\\\%s}{%s}{%s}{%s}{%s}\n"
                         %
                         (utils.latexEsc(self.name), utils.latexEsc(
                             self.id), utils.latexEsc(victim.player.name),
                          utils.latexEsc(victim.player.info),
                          utils.latexEsc(
                              killer.name), utils.latexEsc(
                                  killer.info), utils.latexEsc(victim.id),
                          utils.latexEsc(
                              self.enddate.strftime("%d.%m.%Y %H:%M")),
                          utils.latexEsc(
                              self.url), utils.latexEsc(roundname)))
                     assignments += 1
                 elif len(players) == 1:
                     listfile.write(
                         u"%s hat kein Opfer mehr in Kreis %s.\\\\~\\\\~" %
                         (utils.latexEsc(killer.name), round.name))
             elif len(players) == 1:
                 #listfile.write(u"%s lebt nicht mehr in Kreis %s.\\\\~\\\\~" % (utils.latexEsc(killer.name), round.name))
                 pass
         if assignments > 3:
             listfile.write(u"\\pagebreak\n")
     listfile.close()
     cwd = os.getcwd()
     os.chdir(tmptexdir)
     os.system("xelatex moerder.tex")
     os.chdir(cwd)
     pdfpath = os.path.join(self.savegamedir, "%s.pdf" % fname)
     shutil.copyfile(tmptexdir + "/moerder.pdf", pdfpath)
     return pdfpath
Ejemplo n.º 4
0
	def pdfgen(self, players = None):
		fname = self.id
		if( players is None ):
			players = self.players
		if( len(players) == 0 ):
			return
		elif( len(players) == 1 ):
			fname = self.id + '_' + players[0].public_id
		tmptexdir = "/tmp/moerder_" + fname
		if not os.path.isdir(tmptexdir):
			os.mkdir(tmptexdir)
		tmplfile = "moerder.tex"
		if( len(self.rounds) % 2 == 0 and len(players) > 1 ):
			tmplfile = "moerder2.tex"
		shutil.copyfile(os.path.join(self.templatedir, tmplfile), os.path.join(tmptexdir, "moerder.tex"))
		listfile = codecs.open(os.path.join(tmptexdir, "list.tex"), "w", "utf-8")
		#for roundid,round in self.rounds.iteritems():
		#	for participant in round.participants:
		#		killer = participant.player
		#		victim = round.getInitialVictim(participant).player
		for killer in players:
			for roundid,round in self.rounds.iteritems():
				if round.getParticipant(killer).alive():
					victim = round.getCurrentVictim(killer)
					if victim is not None:
						roundname = round.name if len(self.rounds) > 1 else ''
						#listfile.write("\Auftrag{Gamename}{Gameid}{Victim}{Killer}{Signaturecode}{Spielende}{URL}\n")
						listfile.write(u"\\Auftrag{%s}{%s}{%s\\\\%s}{%s\\\\%s}{%s}{%s}{%s}{%s}\n" % 
							(
								utils.latexEsc(self.name),
								utils.latexEsc(self.id), 
								utils.latexEsc(victim.player.name), 
								utils.latexEsc(victim.player.info), 
								utils.latexEsc(killer.name), 
								utils.latexEsc(killer.info), 
								utils.latexEsc(victim.id), 
								utils.latexEsc(self.enddate.strftime("%d.%m.%Y %H:%M")), 
								utils.latexEsc(self.url), 
								utils.latexEsc(roundname)
							)
						)
					else:
						listfile.write(u"%s hat kein Opfer mehr in Kreis %s.\\\\~\\\\~" % (utils.latexEsc(killer.name), round.name))
				else:
					listfile.write(u"%s lebt nicht mehr in Kreis %s.\\\\~\\\\~" % (utils.latexEsc(killer.name), round.name))
		listfile.close()
		cwd = os.getcwd()
		os.chdir(tmptexdir)
		os.system("xelatex moerder.tex")
		os.chdir(cwd)
		pdfpath = os.path.join(self.savegamedir, "%s.pdf" % fname)
		shutil.copyfile(tmptexdir + "/moerder.pdf", pdfpath)
		return pdfpath