sorcery  Diff

Differences From Artifact [f67589c567]:

  • File calendar.lua — part of check-in [3f6a913e4e] at 2020-09-29 12:40:28 on branch trunk — * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior * initial documentation commit * initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes (user: lexi, size: 2475) [annotate] [blame] [check-ins using]

To Artifact [aec25b4121]:

  • File calendar.lua — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 3372) [annotate] [blame] [check-ins using]

1
2



3
4
5

6
7
8
































9
10
11
12
13
14
15
..
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
..
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
if not sorcery then
	sorcery = { data = {



		calendar = dofile('data/calendar.lua');
		signs = dofile('data/signs.lua');
	} }

end

sorcery.calendar = {}

































sorcery.calendar.stats = function(style)
	if not style then style = sorcery.data.calendar.default end
	local s = sorcery.data.calendar.styles[style]
	local days, moons, weeks = s.days, s.moons, s.weeks

	return {
................................................................................

sorcery.calendar.date = function(day,style)
	local s = sorcery.calendar.stats(style)

	local day_of_year = day % s.days_in_year;
	local day_of_moon = day_of_year % s.days_in_moon;
	local day_of_week = day_of_moon % s.days_in_week;


	return {
		day_of_year = 1 + day_of_year;
		day_of_moon = 1 + day_of_moon;
		day_of_week = 1 + day_of_week;
		week_of_moon = 1 + math.floor(day_of_moon / s.days_in_week);
		week_of_year = 1 + math.floor(day_of_year / s.days_in_week);
		moon_of_year = 1 + math.floor(day_of_year / s.days_in_moon);
		year = math.floor(day / s.days_in_year);
		moons_passed = math.floor(day / s.days_in_moon);
		weeks_passed = math.floor(day / s.days_in_week);


	}
end

sorcery.calendar.stars = function(day,style)
	local periods = math.floor(day / sorcery.data.calendar.days_per_stellar_cycle)

	local elapsed = 0
	local cycle = 1
	while true do
		for _, c in pairs(sorcery.data.signs) do
			if c.cycle then
................................................................................
				}
			end
		::skip::end
		cycle = cycle + 1
	end
end

sorcery.calendar.longdate = function(day)
	if not style then style = sorcery.data.calendar.default end
	return sorcery.data.calendar.styles[style].longdate(sorcery.calendar.date(day))
end

sorcery.calendar.shortdate = function(day,style)
	if not style then style = sorcery.data.calendar.default end
	return sorcery.data.calendar.styles[style].shortdate(sorcery.calendar.date(day))
end

sorcery.calendar.stardate = function(day)
	local s = sorcery.calendar.stars(day)
	return string.format('sign of the %s, stellar cycle %u', s.sign.patron, s.cycle)
end

-- math.randomseed(os.time())
-- local d = math.random(500,256000)
-- print(string.format('%s :: %s in the %s',
-- 	sorcery.calendar.shortdate(d),
-- 	sorcery.calendar.longdate(d),
-- 	sorcery.calendar.stardate(d)))

|
>
>
>


<
>


|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>











>
>



|







 







|

|




|









|
|
|

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
..
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
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
if not sorcery then
	sorcery = {
		lib = { tbl=dofile('lib/tbl.lua') };
	}
	sorcery.data = {
		calendar = dofile('data/calendar.lua');
		signs = dofile('data/signs.lua');

	}
end

sorcery.calendar = {
	moon_phases = {
		[0] = 'New';
		[0.125] = 'Waxing Crescent';
		[0.25] = 'First Quarter';
		[0.375] = 'Waxing Gibbous';
		[0.5] = 'Full';
		[0.625] = 'Waning Gibbous';
		[0.75] = 'Last Quarter';
		[0.875] = 'Waning Crescent';
	};
	timesofday = {
		[0.00] = 'Midnight';
		[0.10] = 'Early Morning';
		[0.25] = 'Morning';
		[0.50] = 'Noon';
		[0.65] = 'Afternoon';
		[0.80] = 'Evening';
		[0.90] = 'Late Evening';
	};
}

sorcery.calendar.contmatch = function(tbl,f)
	local r
	if f>=1 then f = f - math.floor(f) end
	sorcery.lib.tbl.each_o(tbl, function(phase,point)
		if point <= f
			then r=phase
			else return nil, false
		end
	end)
	return r
end

sorcery.calendar.stats = function(style)
	if not style then style = sorcery.data.calendar.default end
	local s = sorcery.data.calendar.styles[style]
	local days, moons, weeks = s.days, s.moons, s.weeks

	return {
................................................................................

sorcery.calendar.date = function(day,style)
	local s = sorcery.calendar.stats(style)

	local day_of_year = day % s.days_in_year;
	local day_of_moon = day_of_year % s.days_in_moon;
	local day_of_week = day_of_moon % s.days_in_week;
	local moon_days = sorcery.data.calendar.days_per_lunar_cycle

	return {
		day_of_year = 1 + day_of_year;
		day_of_moon = 1 + day_of_moon;
		day_of_week = 1 + day_of_week;
		week_of_moon = 1 + math.floor(day_of_moon / s.days_in_week);
		week_of_year = 1 + math.floor(day_of_year / s.days_in_week);
		moon_of_year = 1 + math.floor(day_of_year / s.days_in_moon);
		year = math.floor(day / s.days_in_year);
		moons_passed = math.floor(day / s.days_in_moon);
		weeks_passed = math.floor(day / s.days_in_week);
		lunar_cycle = 1 + math.floor(day / moon_days);
		lunar_phase = (day % moon_days) / moon_days;
	}
end

sorcery.calendar.stars = function(day)
	local periods = math.floor(day / sorcery.data.calendar.days_per_stellar_cycle)

	local elapsed = 0
	local cycle = 1
	while true do
		for _, c in pairs(sorcery.data.signs) do
			if c.cycle then
................................................................................
				}
			end
		::skip::end
		cycle = cycle + 1
	end
end

sorcery.calendar.longdate = function(day,style)
	if not style then style = sorcery.data.calendar.default end
	return sorcery.data.calendar.styles[style].longdate(sorcery.calendar.date(day,style))
end

sorcery.calendar.shortdate = function(day,style)
	if not style then style = sorcery.data.calendar.default end
	return sorcery.data.calendar.styles[style].shortdate(sorcery.calendar.date(day,style))
end

sorcery.calendar.stardate = function(day)
	local s = sorcery.calendar.stars(day)
	return string.format('sign of the %s, stellar cycle %u', s.sign.patron, s.cycle)
end

-- math.randomseed(os.time())
-- local d = math.random(500,256000)
-- print(string.format('%s :: %s under the %s',
-- 	sorcery.calendar.shortdate(d,'magisterial'),
-- 	sorcery.calendar.longdate(d,'magisterial'),
-- 	sorcery.calendar.stardate(d)))