-
Notifications
You must be signed in to change notification settings - Fork 2
/
bill.go
108 lines (104 loc) · 4.21 KB
/
bill.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"bytes"
"log"
"os"
"text/template"
)
var mail = [...]struct {
from, subject string
body *template.Template
}{
{
from: "LRS (Larn Revenue Service)",
subject: "Undeclared Income",
body: template.Must(template.New("body").Parse(
"We have heard you survived the caverns of Larn. Let me be the" +
"\nfirst to congratulate you on your success. It was quite a feat." +
"\nIt was also very profitable for you..." +
"\n\n The Dungeon Master has informed us that you brought" +
"\n{{.Gold}} gold pieces back with you from your journey. As the" +
"\ncounty of Larn is in dire need of funds, we have spared no time" +
"\nin preparing your tax bill. You owe {{.Tax}} gold pieces as" +
"\nof this notice, and is due within 5 days. Failure to pay will" +
"\nmean penalties. Once again, congratulations, We look forward" +
"\nto your future successful expeditions.")),
},
{
from: "His Majesty King Wilfred of Larndom",
subject: "A Noble Deed",
body: template.Must(template.New("body").Parse(
"I have heard of your magnificent feat, and I, King Wilfred," +
"\nforthwith declare today to be a national holiday. Furthermore," +
"\nhence three days, ye be invited to the castle to receive the" +
"\nhonour of Knight of the realm. Upon thy name shall it be written..." +
"\n\nBravery and courage be yours." +
"\n\nMay you live in happiness forevermore...")),
},
{
from: "Count Endelford",
subject: "You Bastard!",
body: template.Must(template.New("body").Parse(
"I have heard (from sources) of your journey. Congratulations!" +
"\nYou Bastard! With several attempts I have yet to endure the" +
" caves,\nand you, a nobody, makes the journey! From this time" +
" onward, be warned\nupon our meeting you shall pay the price!")),
},
{
from: "Mainair, Duke of Larnty",
subject: "High Praise",
body: template.Must(template.New("body").Parse(
"With certainty, a hero I declare to be amongst us! A nod of" +
"\nfavour I send to thee. Me thinks Count Endelford this day of" +
"\nright breath'eth fire as of dragon of whom ye are slayer. I" +
"\nyearn to behold his anger and jealousy. Should ye choose to" +
"\nunleash some of thy wealth upon those who be unfortunate, I," +
"\nDuke Mainair, shall equal thy gift also.")),
},
{
from: "St. Mary's Children's Home",
subject: "these poor children",
body: template.Must(template.New("body").Parse(
"News of your great conquests has spread to all of Larndom." +
"\nMight I have a moment of a great adventurer's time? We here at" +
"\nSt. Mary's Children's Home are very poor, and many children are" +
"\nstarving. Disease is widespread and very often fatal without" +
"\ngood food. Could you possibly find it in your heart to help us" +
"\nin our plight? Whatever you could give will help much." +
"\n(your gift is tax deductible)")),
},
{
from: "The National Cancer Society of Larn",
subject: "hope",
body: template.Must(template.New("body").Parse(
"\nCongratulations on your successful expedition. We are sure much" +
"\ncourage and determination were needed on your quest. There are" +
"\nmany though, that could never hope to undertake such a journey" +
"\ndue to an enfeebling disease -- cancer. We at the National" +
"\nCancer Society of Larn wish to appeal to your philanthropy in" +
"\norder to save many good people -- possibly even yourself a few" +
"\nyears from now. Much work needs to be done in researching this" +
"\ndreaded disease, and you can help today. Could you please see it" +
"\nin your heart to give generously? Your continued good health" +
"\ncan be your everlasting reward.")),
},
}
/*
* function to mail the letters to the player if a winner
*/
func mailbill() {
data := map[string]int{
"Gold": c[GOLD],
"Tax": int(float64(c[GOLD]) * TAXRATE),
}
for _, m := range mail {
var buf bytes.Buffer
if err := m.body.Execute(&buf, data); err != nil {
log.Printf("Failed executing mail body template: %v", err)
continue
}
// TODO: send mail for real.
log.Printf("\nFrom: %s\nSubject: %s\n\n%s", m.from, m.subject, buf.Bytes())
}
os.Exit(0)
}