Difference between revisions of "Battle Reports"

From BattleMaster Wiki
Jump to navigation Jump to search
Line 32: Line 32:
 
==Code to paste in module:==
 
==Code to paste in module:==
 
<pre>Sub BattleConverter()
 
<pre>Sub BattleConverter()
 +
 +
Application.ScreenUpdating = False
 +
'----------------------------------------------------------------------------------------------------------------------------------------------------
 +
'----------------------------------------------Part I: Converting layout from HTML to wiki friendly code---------------------------------------------
 +
'----------------------------------------------------------------------------------------------------------------------------------------------------
  
 
' Remove first section of the text
 
' Remove first section of the text
Line 55: Line 60:
 
IndexOfSW = InStr(1, s, SearchWord2)        ' Returns the location (as number) where the SearchWord2 is first seen
 
IndexOfSW = InStr(1, s, SearchWord2)        ' Returns the location (as number) where the SearchWord2 is first seen
  
 +
If IndexOfSW <> 0 Then
 
' Deletes everything from first letter of search word (- the first letter and <br/> before it) untill the end of the document
 
' Deletes everything from first letter of search word (- the first letter and <br/> before it) untill the end of the document
 
ActiveDocument.Range(Start:=IndexOfSW - 6, End:=Len(ActiveDocument.Content)).Delete
 
ActiveDocument.Range(Start:=IndexOfSW - 6, End:=Len(ActiveDocument.Content)).Delete
 +
End If
  
 
' Create a 2 dimensional Array which holds all values which needs_
 
' Create a 2 dimensional Array which holds all values which needs_
 
' _ to be replaced + their replacement values
 
' _ to be replaced + their replacement values
Dim ReplaceArray(0 To 13, 0 To 1)
+
Dim ReplaceArray(0 To 14, 0 To 1)
 
ReplaceArray(0, 0) = "<Char"
 
ReplaceArray(0, 0) = "<Char"
 
ReplaceArray(0, 1) = "<"
 
ReplaceArray(0, 1) = "<"
Line 100: Line 107:
 
ReplaceArray(12, 1) = "#FF0000"
 
ReplaceArray(12, 1) = "#FF0000"
  
ReplaceArray(13, 0) = "#E0E0FF"      ' Change the light color for 'banners visible' to black
+
ReplaceArray(13, 0) = "#E0E0FF"      ' Change the light color for 'banners visible' to darker readable color that's not exactly black
ReplaceArray(13, 1) = "#000000"
+
ReplaceArray(13, 1) = "#AD6557"
  
ReplaceArray(13, 0) = "#C0FFC0"      ' Change the light green for defenders victory to bright green
+
ReplaceArray(14, 0) = "#C0FFC0"      ' Change the light green for defenders victory to bright green
ReplaceArray(13, 1) = "#00FF00"
+
ReplaceArray(14, 1) = "#00FF00"
  
  
Line 132: Line 139:
  
 
     Next i
 
     Next i
 +
   
 +
'----------------------------------------------------------------------------------------------------------------------------------------------------
 +
'-----------------------------------------------------------------Part II: InfoBox-------------------------------------------------------------------
 +
'----------------------------------------------------------------------------------------------------------------------------------------------------
 +
 +
s = ActiveDocument.Content
 +
   
 +
'The following segment searches and stores the data needed to fill in an InfoBox to automatically be added to the cleaned up _
 +
'Source Code text so it automatically shows the military InfoBox next to the battle report when posting on the wiki
 +
Dim FindRange As Range
 +
Dim Find1
 +
Dim Find2
 +
 +
Dim FindText(0 To 1, 0 To 4)
 +
'Image; Caption;  = N/A
 +
 +
'0 = Conflict; 1 = partof;
 +
'conflict
 +
FindText(0, 0) = "<hr>"
 +
FindText(0, 1) = 13
 +
FindText(0, 2) = "<br>"
 +
FindText(0, 3) = -1
 +
 +
'partof
 +
FindText(1, 0) = "The region owner"
 +
FindText(1, 1) = 16
 +
FindText(1, 2) = "and their allies defend"
 +
FindText(1, 3) = -1
 +
 +
For i = 1 To 2
 +
    Find1 = InStr(s, FindText(i - 1, 0)) + FindText(i - 1, 1)
 +
    Find2 = InStr(s, FindText(i - 1, 2)) + FindText(i - 1, 3)
 +
    Set FindText(i - 1, 4) = ActiveDocument.Range(Start:=Find1, End:=Find2)
 +
Next i
 +
 +
'place
 +
Dim Place As String
 +
Place = "[[" + FindText(0, 4) + "]]"
 +
 +
 +
'Date
 +
Dim DateToday As Date
 +
DateToday = Date
 +
 +
'Weather
 +
Dim Weather As String
 +
If InStr(s, "There is almost no wind today, archers will be deadly") <> 0 Then
 +
    Weather = "No wind"
 +
ElseIf InStr(s, "A calm wind blows, to the joy of the archers") <> 0 Then
 +
    Weather = "Calm wind"
 +
ElseIf InStr(s, "It is quite windy and the archers will have to aim very carefully") <> 0 Then
 +
    Weather = "Quite windy"
 +
ElseIf InStr(s, "Strong winds and gusts are making ranged combat a game of luck") <> 0 Then
 +
    Weather = "Strong wind"
 +
ElseIf InStr(s, "The battle takes place in the middle of a storm, archers will be almost worthless") <> 0 Then
 +
    Weather = "Storm"
 +
Else: Weather = "Error"
 +
End If
 +
 +
'Territory
 +
Dim Territory
 +
Territory = "None"
 +
 +
'Result
 +
Dim Result
 +
If InStr(s, "Attacker Victory") <> 0 Then
 +
    Result = "Attacker Victory"
 +
ElseIf InStr(s, "Defender Victory") <> 0 Then
 +
    Result = "Defender Victory"
 +
Else: Result = "Draw"
 +
End If
 +
 +
'Commander1
 +
Dim CommanderAttack
 +
' *Commander name*, titles, titles, takes command...
 +
' When searching from begin document to turn no. 1, add this to the personal info array (NobleStats) so it can also be checked if he's attack or defender
 +
 +
'strength1 (attackers)
 +
Dim StrengthAttack As String
 +
 +
Find1 = InStr(s, "attackers (") + Len("attackers")                          '"attackers (" is uniquely found only just before all the strength of attacking army
 +
Find2 = InStr(ActiveDocument.Range(Start:=Find1, End:=Find1 + 58), ")")    '+58 because that's the max additional chars possible in between brackets
 +
 +
StrengthAttack = ActiveDocument.Range(Start:=Find1, End:=Find1 + Find2)    ' _of "attackers (# of characters max 48 + margin)"
 +
 +
Find1 = InStr(s, "Total combat strengths:") + Len("Total combat strengths:") '"Total combat strengths:" is unique like 'Total combat strengths x vs. x'
 +
Find2 = InStr(s, " vs. ")
 +
 +
StrengthAttack = ActiveDocument.Range(Start:=Find1, End:=Find2) & "cs " & StrengthAttack
 +
 +
'strength2 (defenders)
 +
Dim StrengthDefense As String
 +
 +
Find1 = InStr(s, "defenders (") + Len("defenders")                          '"defenders (" is uniquely found only just before all the strength of defending army
 +
Find2 = InStr(ActiveDocument.Range(Start:=Find1, End:=Find1 + 58), ")")    '+58 because that's the max additional chars possible in between brackets
 +
 +
StrengthDefense = ActiveDocument.Range(Start:=Find1, End:=Find1 + Find2)    ' _of "attackers (# of characters max 48 + margin)"
 +
 +
Find1 = InStr(s, " vs. ") + Len(" vs.")                                    '" vs. " is unique like 'Total combat strengths x vs. x'
 +
Find2 = InStr(ActiveDocument.Range(Start:=Find1, End:=Find1 + 20), "<br>") - 1 'Find first <br> which comes after the defenders' cs number
 +
 +
StrengthDefense = ActiveDocument.Range(Start:=Find1, End:=Find1 + Find2) & " cs " & StrengthDefense
 +
 +
'rounds
 +
Dim NrTurns As Integer
 +
NrTurns = (Len(s) - Len(Replace(s, "Turn No.", ""))) / 8  'Counts the number of battle turns (/8 because Turn No. has 8 letters).
 +
 +
 +
s = ActiveDocument.Content                              ' Resets s to include all remaining text in document
 +
 +
'The next segment deals with the casulties dealt per turn and adds them to a total casulties per battle
 +
Dim CasualtiesAttack As Integer
 +
Dim CasualtiesDefense As Integer
 +
 +
Dim Turn1 As Long
 +
Dim Turn2 As Long
 +
 +
Dim TurnRange As Range
 +
 +
Dim Find3 As Long
 +
Dim Find4 As Long
 +
 +
Dim b As Integer
 +
 +
CasualtiesAttack = 0
 +
CasualtiesDefense = 0
 +
 +
'Main loop -> deals with # of turns
 +
For b = 1 To 2000
 +
    Turn1 = InStr(s, "Turn No. " & b)                  'Returns the location (as number) where the Turn No. x is first seen
 +
    Turn2 = InStr(s, "Turn No. " & b + 1)              'Returns the next one, so we can select text in between these two
 +
    If Turn2 = 0 Then
 +
        Turn2 = ActiveDocument.Range.End        ' Sets the upperbound of the range to the end of the document
 +
    End If
 +
   
 +
    If Turn1 = 0 Then                            ' If the search in InStr can't be found you get a value of 0;
 +
        Exit For                                        ' Once there's no more higher number, stop the loop
 +
    End If
 +
   
 +
    Set TurnRange = ActiveDocument.Range(Start:=Turn1, End:=Turn2)                                        'Sets range between two turns
 +
   
 +
    'casulties1 (attackers)
 +
    Find1 = InStr(TurnRange, "Total casualties:") + Len("Total casualties:")                              'Searches for the beginning of the number needed
 +
    Find2 = InStr(ActiveDocument.Range(Start:=Turn1 + Find1, End:=Turn1 + Find1 + 20), "attackers") - 1    'Searches for the end of the number needed
 +
   
 +
    CasualtiesAttack = CasualtiesAttack + CInt(ActiveDocument.Range(Start:=Turn1 + Find1, _
 +
                                                End:=Turn1 + Find1 + Find2).Text)                          'Converts the range into text and then to integer. This way they can be added up
 +
     
 +
    'casulties2 (defenders)
 +
    Find3 = Find2 + Len("attackers,")                                                                      'Starts where the other ended + 10 for "attackers,"
 +
    Find4 = InStr(ActiveDocument.Range(Start:=Turn1 + Find1, End:=Turn1 + Find1 + 40), "defenders") - 1    'Searches for the end of the number needed
 +
   
 +
    CasualtiesDefense = CasualtiesDefense + CInt(ActiveDocument.Range(Start:=Turn1 + Find1 + Find3, _
 +
                                                    End:=Turn1 + Find1 + Find4).Text)                      'Converts the range into text and then to integer. This way they can be added up
 +
 +
Next b
 +
 +
'Fills out an infobox. Structure of infobox comes from the battlemaster wiki. This code only takes the variables as defined above and fills them in _
 +
'In the correct places. Kept the general layout of the infobox itself to make it nicer on the eyes.
 +
Dim InfoBox As String
 +
InfoBox = "{{Infobox Military Conflict" & _
 +
"|conflict=" & "Battle of " & FindText(0, 4) & _
 +
"|partof=" & FindText(1, 4) & _
 +
"|image=" & _
 +
"|caption=" & _
 +
"|date=" & Date & _
 +
"|place=" & Place & _
 +
"|weather=" & Weather & _
 +
"|territory=none" & _
 +
"|result=" & Result & _
 +
"|combatant1=" & _
 +
"|combatant2=" & _
 +
"|commander1=" & _
 +
"|commander2=" & _
 +
"|strength1=" & StrengthAttack & _
 +
"|strength2=" & StrengthDefense & _
 +
"|formation1=" & _
 +
"|formation2=" & _
 +
"|rounds=" & NrTurns & _
 +
"|casualties1=" & CasualtiesAttack & _
 +
"|casualties2=" & CasualtiesDefense & _
 +
"}}" & _
 +
"__NOTOC__"
 +
 +
Dim InfoBoxRange As Range
 +
Set InfoBoxRange = ActiveDocument.Range(Start:=0, End:=0)
 +
InfoBoxRange.Text = InfoBox
  
 
End Sub</pre>
 
End Sub</pre>

Revision as of 20:33, 31 May 2018

Addendum by Gabanus

The below pieces have formed the inspiration of what I will share here, but were already outdated again. Nonetheless respect and thanks to Peter Kolak in particular for posting the original piece.

If you want to take a battle report and post it on a website (or the wiki), here's what you have to do:

A. Open a new Microsoft Word File

B. Make sure you have developer mode enabled and preferably added to your ribbon site on how to do this

  1. Click on the developer tab
  2. Click on Visual Basics
  3. Click on insert - Module
  4. Copy following code inside the module
  5. File - Save document -> As File type below the name, pick 'Word Macro - Enabled Content' (both file and the Macro code will be saved together)

C. To make the battle report

  1. you must view a battle report via your scribe report
  2. Click on "View Source" (Paginabron for you Dutchies)
  3. Select the entire source by mouse or use "Ctrl A"
  4. Copy the source by either right clicking and pressing "Copy" or using "Ctrl C"
  5. Open the word document you created earlier
  6. Right click and select "Paste text only" --DON'T JUST NORMALLY PASTE IT, HAVEN'T FIXED THAT PART YET--

  7. Click on the 'Developer tab' in the word document
  8. Click on Macros (next to Visual Basics)
  9. Select the 'BattleConverter' Macro (should be your only one anyway) and click on run

  10. Select all text in the document by mouse or use "Ctrl A"
  11. Open the Wiki page where you want to show the battle report
  12. Copy the text by either right clicking and pressing "Copy" or using "Ctrl C"

Code to paste in module:

Sub BattleConverter()

Application.ScreenUpdating = False
'----------------------------------------------------------------------------------------------------------------------------------------------------
'----------------------------------------------Part I: Converting layout from HTML to wiki friendly code---------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------------------------------

' Remove first section of the text
Dim s
s = ActiveDocument.Content              ' Selects everything (ctrl 'a' basically)

Dim SearchWord1 As String               ' Sets/Defines variables needed for the indexOfThey formula. Easier to change when needed
SearchWord1 = "</center>"

Dim IndexOfSW As Long                ' Returns the location (as number) where the SearchWord1 is first seen
IndexOfSW = InStr(1, s, SearchWord1)

' Deletes everything from start untill first letter of search word + length of word (which includes a potential space after the word)_
' _ + 3 because the 4 characters after the words must be removed as well
ActiveDocument.Range(Start:=0, End:=IndexOfSW + Len(SearchWord1) + 3).Delete

' Remove the last section of text that's not needed
s = ActiveDocument.Content                  ' Resets s to include only the content that remained

Dim SearchWord2 As String
SearchWord2 = "<script"
               
IndexOfSW = InStr(1, s, SearchWord2)        ' Returns the location (as number) where the SearchWord2 is first seen

If IndexOfSW <> 0 Then
' Deletes everything from first letter of search word (- the first letter and <br/> before it) untill the end of the document
ActiveDocument.Range(Start:=IndexOfSW - 6, End:=Len(ActiveDocument.Content)).Delete
End If

' Create a 2 dimensional Array which holds all values which needs_
' _ to be replaced + their replacement values
Dim ReplaceArray(0 To 14, 0 To 1)
ReplaceArray(0, 0) = "<Char"
ReplaceArray(0, 1) = "<"

ReplaceArray(1, 0) = "</Char"
ReplaceArray(1, 1) = "<"

ReplaceArray(2, 0) = "< "
ReplaceArray(2, 1) = "<"

ReplaceArray(3, 0) = "<p>"
ReplaceArray(3, 1) = "<br>"

ReplaceArray(4, 0) = "#000032"  ' Background First table with general overview from dark blue to light gray
ReplaceArray(4, 1) = "#DEDEEA"

ReplaceArray(5, 0) = "#FFFFFF"  ' White text to black (note to self: If you highlight own char as white, it's also changed making it harder to read)
ReplaceArray(5, 1) = "#000000"             '#9696FF blue

ReplaceArray(6, 0) = "color: white" ' Some text color wasn't assigned by Hex colors, but through this code (mixed within the code)
ReplaceArray(6, 1) = "color: black"

ReplaceArray(7, 0) = "<P>"
ReplaceArray(7, 1) = "<br>"

ReplaceArray(8, 0) = "<>"
ReplaceArray(8, 1) = ""

ReplaceArray(9, 0) = "</FONT<"
ReplaceArray(9, 1) = "</FONT><"

ReplaceArray(10, 0) = "> "          ' Some sentences started with a space because there was a space after certain parts of the code. Looked weird
ReplaceArray(10, 1) = ">"

ReplaceArray(11, 0) = "#004000"     ' Background color of the combat tables (the green, making it lighter)
ReplaceArray(11, 1) = "#116811"

ReplaceArray(12, 0) = "#DDDDDD"      ' Change the light color for woundings/captures to bright red
ReplaceArray(12, 1) = "#FF0000"

ReplaceArray(13, 0) = "#E0E0FF"      ' Change the light color for 'banners visible' to darker readable color that's not exactly black
ReplaceArray(13, 1) = "#AD6557"

ReplaceArray(14, 0) = "#C0FFC0"      ' Change the light green for defenders victory to bright green
ReplaceArray(14, 1) = "#00FF00"


' For each Value loop through it and replace it with it's replacement text
Dim i As Long, j As Long

    For i = LBound(ReplaceArray) To UBound(ReplaceArray)
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

    With Selection.Find
        .Text = ReplaceArray(i, 0)
        .Replacement.Text = ReplaceArray(i, 1)
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        
    End With
    Selection.Find.Execute Replace:=wdReplaceAll


    Next i
    
'----------------------------------------------------------------------------------------------------------------------------------------------------
'-----------------------------------------------------------------Part II: InfoBox-------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------------------------------

s = ActiveDocument.Content
    
'The following segment searches and stores the data needed to fill in an InfoBox to automatically be added to the cleaned up _
'Source Code text so it automatically shows the military InfoBox next to the battle report when posting on the wiki
Dim FindRange As Range
Dim Find1
Dim Find2

Dim FindText(0 To 1, 0 To 4)
'Image; Caption;  = N/A

'0 = Conflict; 1 = partof;
'conflict
FindText(0, 0) = "<hr>"
FindText(0, 1) = 13
FindText(0, 2) = "<br>"
FindText(0, 3) = -1

'partof
FindText(1, 0) = "The region owner"
FindText(1, 1) = 16
FindText(1, 2) = "and their allies defend"
FindText(1, 3) = -1

For i = 1 To 2
    Find1 = InStr(s, FindText(i - 1, 0)) + FindText(i - 1, 1)
    Find2 = InStr(s, FindText(i - 1, 2)) + FindText(i - 1, 3)
    Set FindText(i - 1, 4) = ActiveDocument.Range(Start:=Find1, End:=Find2)
Next i

'place
Dim Place As String
Place = "[[" + FindText(0, 4) + "]]"


'Date
Dim DateToday As Date
DateToday = Date

'Weather
Dim Weather As String
If InStr(s, "There is almost no wind today, archers will be deadly") <> 0 Then
    Weather = "No wind"
ElseIf InStr(s, "A calm wind blows, to the joy of the archers") <> 0 Then
    Weather = "Calm wind"
ElseIf InStr(s, "It is quite windy and the archers will have to aim very carefully") <> 0 Then
    Weather = "Quite windy"
ElseIf InStr(s, "Strong winds and gusts are making ranged combat a game of luck") <> 0 Then
    Weather = "Strong wind"
ElseIf InStr(s, "The battle takes place in the middle of a storm, archers will be almost worthless") <> 0 Then
    Weather = "Storm"
Else: Weather = "Error"
End If

'Territory
Dim Territory
Territory = "None"

'Result
Dim Result
If InStr(s, "Attacker Victory") <> 0 Then
    Result = "Attacker Victory"
ElseIf InStr(s, "Defender Victory") <> 0 Then
    Result = "Defender Victory"
Else: Result = "Draw"
End If

'Commander1
Dim CommanderAttack
' *Commander name*, titles, titles, takes command...
' When searching from begin document to turn no. 1, add this to the personal info array (NobleStats) so it can also be checked if he's attack or defender

'strength1 (attackers)
Dim StrengthAttack As String

Find1 = InStr(s, "attackers (") + Len("attackers")                          '"attackers (" is uniquely found only just before all the strength of attacking army
Find2 = InStr(ActiveDocument.Range(Start:=Find1, End:=Find1 + 58), ")")     '+58 because that's the max additional chars possible in between brackets

StrengthAttack = ActiveDocument.Range(Start:=Find1, End:=Find1 + Find2)     ' _of "attackers (# of characters max 48 + margin)"

Find1 = InStr(s, "Total combat strengths:") + Len("Total combat strengths:") '"Total combat strengths:" is unique like 'Total combat strengths x vs. x'
Find2 = InStr(s, " vs. ")

StrengthAttack = ActiveDocument.Range(Start:=Find1, End:=Find2) & "cs " & StrengthAttack

'strength2 (defenders)
Dim StrengthDefense As String

Find1 = InStr(s, "defenders (") + Len("defenders")                          '"defenders (" is uniquely found only just before all the strength of defending army
Find2 = InStr(ActiveDocument.Range(Start:=Find1, End:=Find1 + 58), ")")     '+58 because that's the max additional chars possible in between brackets

StrengthDefense = ActiveDocument.Range(Start:=Find1, End:=Find1 + Find2)    ' _of "attackers (# of characters max 48 + margin)"

Find1 = InStr(s, " vs. ") + Len(" vs.")                                    '" vs. " is unique like 'Total combat strengths x vs. x'
Find2 = InStr(ActiveDocument.Range(Start:=Find1, End:=Find1 + 20), "<br>") - 1 'Find first <br> which comes after the defenders' cs number

StrengthDefense = ActiveDocument.Range(Start:=Find1, End:=Find1 + Find2) & " cs " & StrengthDefense

'rounds
Dim NrTurns As Integer
NrTurns = (Len(s) - Len(Replace(s, "Turn No.", ""))) / 8  'Counts the number of battle turns (/8 because Turn No. has 8 letters).


s = ActiveDocument.Content                              ' Resets s to include all remaining text in document

'The next segment deals with the casulties dealt per turn and adds them to a total casulties per battle
Dim CasualtiesAttack As Integer
Dim CasualtiesDefense As Integer

Dim Turn1 As Long
Dim Turn2 As Long

Dim TurnRange As Range

Dim Find3 As Long
Dim Find4 As Long

Dim b As Integer

CasualtiesAttack = 0
CasualtiesDefense = 0

'Main loop -> deals with # of turns
For b = 1 To 2000
    Turn1 = InStr(s, "Turn No. " & b)                   'Returns the location (as number) where the Turn No. x is first seen
    Turn2 = InStr(s, "Turn No. " & b + 1)               'Returns the next one, so we can select text in between these two
    If Turn2 = 0 Then
        Turn2 = ActiveDocument.Range.End        ' Sets the upperbound of the range to the end of the document
    End If
    
    If Turn1 = 0 Then                            ' If the search in InStr can't be found you get a value of 0;
        Exit For                                        ' Once there's no more higher number, stop the loop
    End If
    
    Set TurnRange = ActiveDocument.Range(Start:=Turn1, End:=Turn2)                                         'Sets range between two turns
    
    'casulties1 (attackers)
    Find1 = InStr(TurnRange, "Total casualties:") + Len("Total casualties:")                               'Searches for the beginning of the number needed
    Find2 = InStr(ActiveDocument.Range(Start:=Turn1 + Find1, End:=Turn1 + Find1 + 20), "attackers") - 1    'Searches for the end of the number needed
    
    CasualtiesAttack = CasualtiesAttack + CInt(ActiveDocument.Range(Start:=Turn1 + Find1, _
                                                End:=Turn1 + Find1 + Find2).Text)                          'Converts the range into text and then to integer. This way they can be added up
      
    'casulties2 (defenders)
    Find3 = Find2 + Len("attackers,")                                                                      'Starts where the other ended + 10 for "attackers,"
    Find4 = InStr(ActiveDocument.Range(Start:=Turn1 + Find1, End:=Turn1 + Find1 + 40), "defenders") - 1    'Searches for the end of the number needed
    
    CasualtiesDefense = CasualtiesDefense + CInt(ActiveDocument.Range(Start:=Turn1 + Find1 + Find3, _
                                                    End:=Turn1 + Find1 + Find4).Text)                      'Converts the range into text and then to integer. This way they can be added up

Next b

'Fills out an infobox. Structure of infobox comes from the battlemaster wiki. This code only takes the variables as defined above and fills them in _
'In the correct places. Kept the general layout of the infobox itself to make it nicer on the eyes.
Dim InfoBox As String
InfoBox = "{{Infobox Military Conflict" & _
"|conflict=" & "Battle of " & FindText(0, 4) & _
"|partof=" & FindText(1, 4) & _
"|image=" & _
"|caption=" & _
"|date=" & Date & _
"|place=" & Place & _
"|weather=" & Weather & _
"|territory=none" & _
"|result=" & Result & _
"|combatant1=" & _
"|combatant2=" & _
"|commander1=" & _
"|commander2=" & _
"|strength1=" & StrengthAttack & _
"|strength2=" & StrengthDefense & _
"|formation1=" & _
"|formation2=" & _
"|rounds=" & NrTurns & _
"|casualties1=" & CasualtiesAttack & _
"|casualties2=" & CasualtiesDefense & _
"}}" & _
"__NOTOC__"

Dim InfoBoxRange As Range
Set InfoBoxRange = ActiveDocument.Range(Start:=0, End:=0)
InfoBoxRange.Text = InfoBox

End Sub

By: Peter Kolak


If you want to take a battle report and post it on a website, here's what you have to do:

A. Taking the scribe report and putting it in Word.

  1. First, you must view a battle report via your scribe report.
  2. Click on "View Source".
  3. Copy the source by either right clicking and pressing "Copy" or using "Ctrl P".
  4. Open up a Word Document.
  5. Right click and select "Paste" or simply type "Ctrl V".


B. Editing the text for the web page. Use "Find and Replace" and follow the next 13 steps.

  1. Replace "<Char" with "<".
  2. Replace "</Char" with "<".
  3. Replace "<_" with "<". (Where as "_" is equal to ONE blank space.)
  4. Replace "<^#^#^#^#^#>" with "". (Meaning, don't replace it with anything, just leave the replace section blank.
  5. Replace "<^#^#^#^#>" with "".
  6. Replace "<^#^#^#>" with "".
  7. Replace "<^#^#>" with "".
  8. Replace "< p >" with "< br >" (There are no spaces between the "<" and the "p".
  9. Replace "#DDDDDD" with "#00FFFF".
  10. Replace "#FFFFFF" with "#FFDD11".
  11. Replace "#E0E0FF" with "#FF00DD".
  12. Delete top several rows that contains header information.
  13. Delete very last info: "</Body></HTML>".

C. Preview and make sure it looks good.

Peter Kolak

Addendum by RubyDragon

Having used these steps quite often in the Falasan Inquirer, I found them to be incredibly useful, but here are some modifications which will help fix some of the bugs I found.

A. -no change

B. Editing the text for the web page. Use "Find and Replace" and follow the next 13 steps.

  1. Replace "<Char" with "<".
  2. Replace "</Char" with "<".
  3. Replace "<_" with "<". (Where as "_" is equal to ONE blank space.)
  4. Replace "<^#^#^#^#^#>" with "". (Meaning, don't replace it with anything, just leave the replace section blank.
  5. Replace "<^#^#^#^#>" with "".
  6. Replace "<^#^#^#>" with "".
  7. Replace "<^#^#>" with "". (never found any of these myself)
  8. Replace "< p >" with "< br >" (There are no spaces between the "<" and the "p".
  9. Replace "#DDDDDD" with "#00FFFF".
  10. Replace "#FFFFFF" with "#FFDD11".
  11. Replace "#E0E0FF" with "#FF00DD".
  12. Delete top several rows that contains header information. Delete everything above and including the following phrase found near the beginning "Scribe Note, X turns old:"
  13. Delete very last info: "</Body></HTML>".
"
</BODY>
</HTML><script language='javascript'>postamble();</script>"

RubyDragon's Additions
After doing B (with modifications, carry out the following:

  1. Replace "<>" with "".This removes all those odd "<>" speckling the report
  2. Replace "</FONT<" with "<" I noticed that if this weren't done, after a certain point all writing became yellow)
  3. Preview the battle report. You should notice a near the top. It is located after the "Scribe Note: Battle in XXXYYY", immediately behind "FormationCS"

C. Preview, make sure it looks good, and edit out anything that looks weird.

Addendum by Ceorl

  1. Replace "</FONT<" with "<".
  2. Replace "< p >" with "< br >". (There are no spaces between the "<" and the "p".
  3. Replace "< /p >" with "". (There are no spaces between the "<" and the "/p".
  4. Replace "<Char" with "<".
  5. Replace "</Char" with "<".
  6. Replace "<_" with "<". (Where as "_" is equal to ONE blank space.)
  7. Replace "<>" with "".
  8. Replace "white" with "black".
  9. Replace "#DDDDDD" with "#DC143C"
  10. Replace "#FFFFFF" with "#00008B"
  11. Replace "#E0E0FF" with "#A52A2A"
  12. Replace "#C0FFC0" with "#00008B" (This is for Defender Victory)
  13. Replace "#FFC0C0" with "#DC143C" (This is for Attacker Victory)
  14. Replace "#E0FFFF" with "#00008B"